{"id":2068,"date":"2017-01-23T21:34:56","date_gmt":"2017-01-24T02:34:56","guid":{"rendered":"https:\/\/bitpost.com\/news\/?p=2068"},"modified":"2017-01-23T21:34:56","modified_gmt":"2017-01-24T02:34:56","slug":"solve-excel-problems-with-sql","status":"publish","type":"post","link":"https:\/\/bitpost.com\/news\/2017\/solve-excel-problems-with-sql\/","title":{"rendered":"Solve Excel problems with SQL"},"content":{"rendered":"<p>A friend of mine asked for help to do a complicated data pivot on a few thousand rows of data. \u00a0We discussed it and agreed that we probably needed to walk each row\u00a0and do an algorithmic summation on the fly.<\/p>\n<p>My first instinct was to fire up Windows and dust off the old VBA cobwebs in my mind. \u00a0Fortunately that didn&#8217;t last long, and I reached for a far more comfortable friend, SQL. \u00a0The final SQL wasn&#8217;t terribly simple, but wasn&#8217;t terribly complicated either. \u00a0And it was a total linux solution, always the more pleasant solution. \u00a0And totally gui, too, for all you folks who\u00a0get hives when you have to bang at a terminal. \u00a0\ud83d\ude42<\/p>\n<ul>\n<li>Open excel sheet in LibreOffice<\/li>\n<li>Copy columns of interest into a new sheet<\/li>\n<li>Save As -&gt; Text CSV<\/li>\n<li>Create a sqlitebrowser database<\/li>\n<li>Import the CSV file as a new table<\/li>\n<\/ul>\n<p>BAM, easy, powerful, free, cheap, fast, win, win, win!<\/p>\n<p>I ended up using this sql, the key is sqlite&#8217;s\u00a0group_concat(), which just jams a whole query into one field, ha, boom.<\/p>\n<pre><code>SELECT a.email<\/code>\r\n<code> , group_concat(d.Dates) AS Dates<\/code>\r\n<code> , group_concat(d.Values) ASValues<\/code>\r\n<code>FROM (select * from TestData\u00a0ORDER BY email,Dates) AS a<\/code>\r\n<code>inner JOIN TestData AS d ON d.email = a.email<\/code>\r\n<code>GROUP BY a.email;<\/code><\/pre>\n<p>Then I copied\u00a0the tabular result of the query, and pasted into\u00a0the LibreOffice\u00a0sheet, which asked me how to import. \u00a0Delimited by tab and comma, and then always recheck &#8220;select text delimiter&#8221; and use a comma. \u00a0And the cells fill right up.<\/p>\n<p>All is full of light.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>A friend of mine asked for help to do a complicated data pivot on a few thousand rows of data. \u00a0We discussed it and agreed that we probably needed to walk each row\u00a0and do an algorithmic summation on the fly. My first instinct was to fire up Windows and dust off the old VBA cobwebs [&hellip;]<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_jetpack_newsletter_access":"","_jetpack_dont_email_post_to_subs":false,"_jetpack_newsletter_tier_id":0,"_jetpack_memberships_contains_paywalled_content":false,"_jetpack_feature_clip_id":0,"_jetpack_memberships_contains_paid_content":false,"footnotes":"","jetpack_publicize_message":"","jetpack_publicize_feature_enabled":true,"jetpack_social_post_already_shared":false,"jetpack_social_options":{"image_generator_settings":{"template":"highway","default_image_id":0,"font":"","enabled":false},"version":2},"jetpack_post_was_ever_published":false},"categories":[19,10],"tags":[263,264,262,261],"class_list":["post-2068","post","type-post","status-publish","format-standard","hentry","category-opensource","category-tricks-tips-tools","tag-excel","tag-group_concat","tag-sql","tag-sqlite"],"aioseo_notices":[],"aioseo_head":"\n\t\t<!-- All in One SEO 4.9.9 - aioseo.com -->\n\t<meta name=\"description\" content=\"A friend of mine asked for help to do a complicated data pivot on a few thousand rows of data. We discussed it and agreed that we probably needed to walk each row and do an algorithmic summation on the fly. My first instinct was to fire up Windows and dust off the old VBA cobwebs\" \/>\n\t<meta name=\"robots\" content=\"max-image-preview:large\" \/>\n\t<meta name=\"author\" content=\"m\"\/>\n\t<meta name=\"keywords\" content=\"open source,tricks tips tools\" \/>\n\t<link rel=\"canonical\" href=\"https:\/\/bitpost.com\/news\/2017\/solve-excel-problems-with-sql\/\" \/>\n\t<meta name=\"generator\" content=\"All in One SEO (AIOSEO) 4.9.9\" \/>\n\t\t<meta property=\"og:locale\" content=\"en_US\" \/>\n\t\t<meta property=\"og:site_name\" content=\"bitpost.com\/news | Note to self\" \/>\n\t\t<meta property=\"og:type\" content=\"article\" \/>\n\t\t<meta property=\"og:title\" content=\"Solve Excel problems with SQL | bitpost.com\/news\" \/>\n\t\t<meta property=\"og:description\" content=\"A friend of mine asked for help to do a complicated data pivot on a few thousand rows of data. We discussed it and agreed that we probably needed to walk each row and do an algorithmic summation on the fly. My first instinct was to fire up Windows and dust off the old VBA cobwebs\" \/>\n\t\t<meta property=\"og:url\" content=\"https:\/\/bitpost.com\/news\/2017\/solve-excel-problems-with-sql\/\" \/>\n\t\t<meta property=\"article:published_time\" content=\"2017-01-24T02:34:56+00:00\" \/>\n\t\t<meta property=\"article:modified_time\" content=\"2017-01-24T02:34:56+00:00\" \/>\n\t\t<meta name=\"twitter:card\" content=\"summary\" \/>\n\t\t<meta name=\"twitter:title\" content=\"Solve Excel problems with SQL | bitpost.com\/news\" \/>\n\t\t<meta name=\"twitter:description\" content=\"A friend of mine asked for help to do a complicated data pivot on a few thousand rows of data. We discussed it and agreed that we probably needed to walk each row and do an algorithmic summation on the fly. My first instinct was to fire up Windows and dust off the old VBA cobwebs\" \/>\n\t\t<script type=\"application\/ld+json\" class=\"aioseo-schema\">\n\t\t\t{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\\\/\\\/bitpost.com\\\/news\\\/2017\\\/solve-excel-problems-with-sql\\\/#article\",\"name\":\"Solve Excel problems with SQL | bitpost.com\\\/news\",\"headline\":\"Solve Excel problems with SQL\",\"author\":{\"@id\":\"https:\\\/\\\/bitpost.com\\\/news\\\/author\\\/m\\\/#author\"},\"publisher\":{\"@id\":\"https:\\\/\\\/bitpost.com\\\/news\\\/#person\"},\"image\":{\"@type\":\"ImageObject\",\"@id\":\"https:\\\/\\\/bitpost.com\\\/news\\\/2017\\\/solve-excel-problems-with-sql\\\/#articleImage\",\"url\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/884c1dbbf1027f261dbf20652687af7ad0030bfa71ff0ef56540938bdc70be2f?s=96&d=monsterid&r=pg\",\"width\":96,\"height\":96,\"caption\":\"m\"},\"datePublished\":\"2017-01-23T21:34:56-05:00\",\"dateModified\":\"2017-01-23T21:34:56-05:00\",\"inLanguage\":\"en-US\",\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/bitpost.com\\\/news\\\/2017\\\/solve-excel-problems-with-sql\\\/#webpage\"},\"isPartOf\":{\"@id\":\"https:\\\/\\\/bitpost.com\\\/news\\\/2017\\\/solve-excel-problems-with-sql\\\/#webpage\"},\"articleSection\":\"Open Source, Tricks Tips Tools, excel, group_concat, sql, sqlite\"},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/bitpost.com\\\/news\\\/2017\\\/solve-excel-problems-with-sql\\\/#breadcrumblist\",\"itemListElement\":[{\"@type\":\"ListItem\",\"@id\":\"https:\\\/\\\/bitpost.com\\\/news#listItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\\\/\\\/bitpost.com\\\/news\",\"nextItem\":{\"@type\":\"ListItem\",\"@id\":\"https:\\\/\\\/bitpost.com\\\/news\\\/category\\\/projects\\\/#listItem\",\"name\":\"Projects\"}},{\"@type\":\"ListItem\",\"@id\":\"https:\\\/\\\/bitpost.com\\\/news\\\/category\\\/projects\\\/#listItem\",\"position\":2,\"name\":\"Projects\",\"item\":\"https:\\\/\\\/bitpost.com\\\/news\\\/category\\\/projects\\\/\",\"nextItem\":{\"@type\":\"ListItem\",\"@id\":\"https:\\\/\\\/bitpost.com\\\/news\\\/category\\\/projects\\\/opensource\\\/#listItem\",\"name\":\"Open Source\"},\"previousItem\":{\"@type\":\"ListItem\",\"@id\":\"https:\\\/\\\/bitpost.com\\\/news#listItem\",\"name\":\"Home\"}},{\"@type\":\"ListItem\",\"@id\":\"https:\\\/\\\/bitpost.com\\\/news\\\/category\\\/projects\\\/opensource\\\/#listItem\",\"position\":3,\"name\":\"Open Source\",\"item\":\"https:\\\/\\\/bitpost.com\\\/news\\\/category\\\/projects\\\/opensource\\\/\",\"nextItem\":{\"@type\":\"ListItem\",\"@id\":\"https:\\\/\\\/bitpost.com\\\/news\\\/2017\\\/solve-excel-problems-with-sql\\\/#listItem\",\"name\":\"Solve Excel problems with SQL\"},\"previousItem\":{\"@type\":\"ListItem\",\"@id\":\"https:\\\/\\\/bitpost.com\\\/news\\\/category\\\/projects\\\/#listItem\",\"name\":\"Projects\"}},{\"@type\":\"ListItem\",\"@id\":\"https:\\\/\\\/bitpost.com\\\/news\\\/2017\\\/solve-excel-problems-with-sql\\\/#listItem\",\"position\":4,\"name\":\"Solve Excel problems with SQL\",\"previousItem\":{\"@type\":\"ListItem\",\"@id\":\"https:\\\/\\\/bitpost.com\\\/news\\\/category\\\/projects\\\/opensource\\\/#listItem\",\"name\":\"Open Source\"}}]},{\"@type\":\"Person\",\"@id\":\"https:\\\/\\\/bitpost.com\\\/news\\\/#person\",\"name\":\"m\",\"image\":{\"@type\":\"ImageObject\",\"@id\":\"https:\\\/\\\/bitpost.com\\\/news\\\/2017\\\/solve-excel-problems-with-sql\\\/#personImage\",\"url\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/884c1dbbf1027f261dbf20652687af7ad0030bfa71ff0ef56540938bdc70be2f?s=96&d=monsterid&r=pg\",\"width\":96,\"height\":96,\"caption\":\"m\"}},{\"@type\":\"Person\",\"@id\":\"https:\\\/\\\/bitpost.com\\\/news\\\/author\\\/m\\\/#author\",\"url\":\"https:\\\/\\\/bitpost.com\\\/news\\\/author\\\/m\\\/\",\"name\":\"m\",\"image\":{\"@type\":\"ImageObject\",\"@id\":\"https:\\\/\\\/bitpost.com\\\/news\\\/2017\\\/solve-excel-problems-with-sql\\\/#authorImage\",\"url\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/884c1dbbf1027f261dbf20652687af7ad0030bfa71ff0ef56540938bdc70be2f?s=96&d=monsterid&r=pg\",\"width\":96,\"height\":96,\"caption\":\"m\"}},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/bitpost.com\\\/news\\\/2017\\\/solve-excel-problems-with-sql\\\/#webpage\",\"url\":\"https:\\\/\\\/bitpost.com\\\/news\\\/2017\\\/solve-excel-problems-with-sql\\\/\",\"name\":\"Solve Excel problems with SQL | bitpost.com\\\/news\",\"description\":\"A friend of mine asked for help to do a complicated data pivot on a few thousand rows of data. We discussed it and agreed that we probably needed to walk each row and do an algorithmic summation on the fly. My first instinct was to fire up Windows and dust off the old VBA cobwebs\",\"inLanguage\":\"en-US\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/bitpost.com\\\/news\\\/#website\"},\"breadcrumb\":{\"@id\":\"https:\\\/\\\/bitpost.com\\\/news\\\/2017\\\/solve-excel-problems-with-sql\\\/#breadcrumblist\"},\"author\":{\"@id\":\"https:\\\/\\\/bitpost.com\\\/news\\\/author\\\/m\\\/#author\"},\"creator\":{\"@id\":\"https:\\\/\\\/bitpost.com\\\/news\\\/author\\\/m\\\/#author\"},\"datePublished\":\"2017-01-23T21:34:56-05:00\",\"dateModified\":\"2017-01-23T21:34:56-05:00\"},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/bitpost.com\\\/news\\\/#website\",\"url\":\"https:\\\/\\\/bitpost.com\\\/news\\\/\",\"name\":\"bitpost.com\\\/news\",\"description\":\"Note to self\",\"inLanguage\":\"en-US\",\"publisher\":{\"@id\":\"https:\\\/\\\/bitpost.com\\\/news\\\/#person\"}}]}\n\t\t<\/script>\n\t\t<!-- All in One SEO -->\n\n","aioseo_head_json":{"title":"Solve Excel problems with SQL | bitpost.com\/news","description":"A friend of mine asked for help to do a complicated data pivot on a few thousand rows of data. We discussed it and agreed that we probably needed to walk each row and do an algorithmic summation on the fly. My first instinct was to fire up Windows and dust off the old VBA cobwebs","canonical_url":"https:\/\/bitpost.com\/news\/2017\/solve-excel-problems-with-sql\/","robots":"max-image-preview:large","keywords":"open source,tricks tips tools","webmasterTools":{"miscellaneous":""},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/bitpost.com\/news\/2017\/solve-excel-problems-with-sql\/#article","name":"Solve Excel problems with SQL | bitpost.com\/news","headline":"Solve Excel problems with SQL","author":{"@id":"https:\/\/bitpost.com\/news\/author\/m\/#author"},"publisher":{"@id":"https:\/\/bitpost.com\/news\/#person"},"image":{"@type":"ImageObject","@id":"https:\/\/bitpost.com\/news\/2017\/solve-excel-problems-with-sql\/#articleImage","url":"https:\/\/secure.gravatar.com\/avatar\/884c1dbbf1027f261dbf20652687af7ad0030bfa71ff0ef56540938bdc70be2f?s=96&d=monsterid&r=pg","width":96,"height":96,"caption":"m"},"datePublished":"2017-01-23T21:34:56-05:00","dateModified":"2017-01-23T21:34:56-05:00","inLanguage":"en-US","mainEntityOfPage":{"@id":"https:\/\/bitpost.com\/news\/2017\/solve-excel-problems-with-sql\/#webpage"},"isPartOf":{"@id":"https:\/\/bitpost.com\/news\/2017\/solve-excel-problems-with-sql\/#webpage"},"articleSection":"Open Source, Tricks Tips Tools, excel, group_concat, sql, sqlite"},{"@type":"BreadcrumbList","@id":"https:\/\/bitpost.com\/news\/2017\/solve-excel-problems-with-sql\/#breadcrumblist","itemListElement":[{"@type":"ListItem","@id":"https:\/\/bitpost.com\/news#listItem","position":1,"name":"Home","item":"https:\/\/bitpost.com\/news","nextItem":{"@type":"ListItem","@id":"https:\/\/bitpost.com\/news\/category\/projects\/#listItem","name":"Projects"}},{"@type":"ListItem","@id":"https:\/\/bitpost.com\/news\/category\/projects\/#listItem","position":2,"name":"Projects","item":"https:\/\/bitpost.com\/news\/category\/projects\/","nextItem":{"@type":"ListItem","@id":"https:\/\/bitpost.com\/news\/category\/projects\/opensource\/#listItem","name":"Open Source"},"previousItem":{"@type":"ListItem","@id":"https:\/\/bitpost.com\/news#listItem","name":"Home"}},{"@type":"ListItem","@id":"https:\/\/bitpost.com\/news\/category\/projects\/opensource\/#listItem","position":3,"name":"Open Source","item":"https:\/\/bitpost.com\/news\/category\/projects\/opensource\/","nextItem":{"@type":"ListItem","@id":"https:\/\/bitpost.com\/news\/2017\/solve-excel-problems-with-sql\/#listItem","name":"Solve Excel problems with SQL"},"previousItem":{"@type":"ListItem","@id":"https:\/\/bitpost.com\/news\/category\/projects\/#listItem","name":"Projects"}},{"@type":"ListItem","@id":"https:\/\/bitpost.com\/news\/2017\/solve-excel-problems-with-sql\/#listItem","position":4,"name":"Solve Excel problems with SQL","previousItem":{"@type":"ListItem","@id":"https:\/\/bitpost.com\/news\/category\/projects\/opensource\/#listItem","name":"Open Source"}}]},{"@type":"Person","@id":"https:\/\/bitpost.com\/news\/#person","name":"m","image":{"@type":"ImageObject","@id":"https:\/\/bitpost.com\/news\/2017\/solve-excel-problems-with-sql\/#personImage","url":"https:\/\/secure.gravatar.com\/avatar\/884c1dbbf1027f261dbf20652687af7ad0030bfa71ff0ef56540938bdc70be2f?s=96&d=monsterid&r=pg","width":96,"height":96,"caption":"m"}},{"@type":"Person","@id":"https:\/\/bitpost.com\/news\/author\/m\/#author","url":"https:\/\/bitpost.com\/news\/author\/m\/","name":"m","image":{"@type":"ImageObject","@id":"https:\/\/bitpost.com\/news\/2017\/solve-excel-problems-with-sql\/#authorImage","url":"https:\/\/secure.gravatar.com\/avatar\/884c1dbbf1027f261dbf20652687af7ad0030bfa71ff0ef56540938bdc70be2f?s=96&d=monsterid&r=pg","width":96,"height":96,"caption":"m"}},{"@type":"WebPage","@id":"https:\/\/bitpost.com\/news\/2017\/solve-excel-problems-with-sql\/#webpage","url":"https:\/\/bitpost.com\/news\/2017\/solve-excel-problems-with-sql\/","name":"Solve Excel problems with SQL | bitpost.com\/news","description":"A friend of mine asked for help to do a complicated data pivot on a few thousand rows of data. We discussed it and agreed that we probably needed to walk each row and do an algorithmic summation on the fly. My first instinct was to fire up Windows and dust off the old VBA cobwebs","inLanguage":"en-US","isPartOf":{"@id":"https:\/\/bitpost.com\/news\/#website"},"breadcrumb":{"@id":"https:\/\/bitpost.com\/news\/2017\/solve-excel-problems-with-sql\/#breadcrumblist"},"author":{"@id":"https:\/\/bitpost.com\/news\/author\/m\/#author"},"creator":{"@id":"https:\/\/bitpost.com\/news\/author\/m\/#author"},"datePublished":"2017-01-23T21:34:56-05:00","dateModified":"2017-01-23T21:34:56-05:00"},{"@type":"WebSite","@id":"https:\/\/bitpost.com\/news\/#website","url":"https:\/\/bitpost.com\/news\/","name":"bitpost.com\/news","description":"Note to self","inLanguage":"en-US","publisher":{"@id":"https:\/\/bitpost.com\/news\/#person"}}]},"og:locale":"en_US","og:site_name":"bitpost.com\/news | Note to self","og:type":"article","og:title":"Solve Excel problems with SQL | bitpost.com\/news","og:description":"A friend of mine asked for help to do a complicated data pivot on a few thousand rows of data. We discussed it and agreed that we probably needed to walk each row and do an algorithmic summation on the fly. My first instinct was to fire up Windows and dust off the old VBA cobwebs","og:url":"https:\/\/bitpost.com\/news\/2017\/solve-excel-problems-with-sql\/","article:published_time":"2017-01-24T02:34:56+00:00","article:modified_time":"2017-01-24T02:34:56+00:00","twitter:card":"summary","twitter:title":"Solve Excel problems with SQL | bitpost.com\/news","twitter:description":"A friend of mine asked for help to do a complicated data pivot on a few thousand rows of data. We discussed it and agreed that we probably needed to walk each row and do an algorithmic summation on the fly. My first instinct was to fire up Windows and dust off the old VBA cobwebs"},"aioseo_meta_data":{"post_id":"2068","title":null,"description":null,"keywords":null,"keyphrases":null,"primary_term":null,"canonical_url":null,"og_title":null,"og_description":null,"og_object_type":"default","og_image_type":"default","og_image_url":null,"og_image_width":null,"og_image_height":null,"og_image_custom_url":null,"og_image_custom_fields":null,"og_video":null,"og_custom_url":null,"og_article_section":null,"og_article_tags":null,"twitter_use_og":false,"twitter_card":"default","twitter_image_type":"default","twitter_image_url":null,"twitter_image_custom_url":null,"twitter_image_custom_fields":null,"twitter_title":null,"twitter_description":null,"schema":{"blockGraphs":[],"customGraphs":[],"default":{"data":{"Article":[],"Course":[],"Dataset":[],"FAQPage":[],"Movie":[],"Person":[],"Product":[],"ProductReview":[],"Car":[],"Recipe":[],"Service":[],"SoftwareApplication":[],"WebPage":[]},"graphName":"","isEnabled":true},"graphs":[],"defaultGraph":"","defaultPostTypeGraph":""},"schema_type":null,"schema_type_options":null,"pillar_content":false,"robots_default":true,"robots_noindex":false,"robots_noarchive":false,"robots_nosnippet":false,"robots_nofollow":false,"robots_noimageindex":false,"robots_noodp":false,"robots_notranslate":false,"robots_max_snippet":null,"robots_max_videopreview":null,"robots_max_imagepreview":"large","priority":null,"frequency":null,"local_seo":null,"breadcrumb_settings":null,"limit_modified_date":false,"ai":null,"created":"2021-03-13 19:46:02","updated":"2025-08-17 19:15:28","seo_analyzer_scan_date":null},"jetpack_publicize_connections":[],"jetpack_featured_media_url":"","jetpack_sharing_enabled":true,"jetpack_shortlink":"https:\/\/wp.me\/p9M11L-xm","jetpack_likes_enabled":true,"_links":{"self":[{"href":"https:\/\/bitpost.com\/news\/wp-json\/wp\/v2\/posts\/2068","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/bitpost.com\/news\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/bitpost.com\/news\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/bitpost.com\/news\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/bitpost.com\/news\/wp-json\/wp\/v2\/comments?post=2068"}],"version-history":[{"count":1,"href":"https:\/\/bitpost.com\/news\/wp-json\/wp\/v2\/posts\/2068\/revisions"}],"predecessor-version":[{"id":2069,"href":"https:\/\/bitpost.com\/news\/wp-json\/wp\/v2\/posts\/2068\/revisions\/2069"}],"wp:attachment":[{"href":"https:\/\/bitpost.com\/news\/wp-json\/wp\/v2\/media?parent=2068"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/bitpost.com\/news\/wp-json\/wp\/v2\/categories?post=2068"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/bitpost.com\/news\/wp-json\/wp\/v2\/tags?post=2068"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}