{"prompt": "I made a SQL Interview Cheat Sheet for data professionals. What would you add?", "completion": "I made a SQL Interview Cheat Sheet for data professionals. What would you add?\nI put together a one-page SQL interview cheat sheet covering the stuff I keep seeing come up in analyst/data interviews.\n\nIncluded joins, aggregations, CTEs, NULL handling, window functions, common interview patterns and a few mistakes that can make a query look correct while giving the wrong result.\n\nI tried to focus a bit more on problem solving than just memorizing syntax.\n\nWhat am I missing?\n\nEspecially interested in the SQL patterns you’ve actually been asked during interviews.", "subreddit": "r/SQL", "upvotes": 435, "date": "[PHONE]", "source": "https://www.reddit.com/r/SQL/comments/1w3cl3c/i_made_a_sql_interview_cheat_sheet_for_data/"}
{"prompt": "I finally understood window functions and I'm not the same person anymore", "completion": "I finally understood window functions and I'm not the same person anymore\n\"For context: I've been writing SQL for about a year at work, mostly basic SELECTs, JOINs, GROUP BYs. Window functions were on my \"\"I'll learn them eventually\"\" list for way too long.\n\nThis week my manager asked me to calculate a running 7-day average for daily active users, broken out by signup cohort. Past-me would have exported to Python or built some weird self-join nightmare. Instead I sat down with a coffee and forced myself to actually learn OVER and PARTITION BY.\n\nIt clicked when I stopped thinking of them as aggregations and started thinking of them as \"\"give me this calculation for each row, but with context from these other rows.\"\" Once that flipped in my head, ROW\\_NUMBER, LAG, LEAD, all of it made sense in about 20 minutes.\n\nFor anyone else putting this off: do it. I rewrote three of my old reports this week and they're like 80% shorter and actually readable.\n\nWhat was the SQL concept that took the longest to click for you?\"", "subreddit": "r/SQL", "upvotes": 430, "date": "[PHONE]", "source": "https://www.reddit.com/r/SQL/comments/1tbdc7e/i_finally_understood_window_functions_and_im_not/"}
{"prompt": "Chrome extension to run SQL in Google Sheets", "completion": "Chrome extension to run SQL in Google Sheets\nWe hate dragging formulas in Google Sheets.\n\nSo we built a clean way to run real SQL directly inside Google Sheets, fully local with no setup.\n\nFeedback appreciated!\n\n[https://chromewebstore.google.com/detail/sql4sheets-run-real-sql-i/glpifbibcakmdmceihjkiffilclajpmf](https://chromewebstore.google.com/detail/sql4sheets-run-real-sql-i/glpifbibcakmdmceihjkiffilclajpmf)", "subreddit": "r/SQL", "upvotes": 331, "date": "[PHONE]", "source": "https://www.reddit.com/r/SQL/comments/1q4r6xg/chrome_extension_to_run_sql_in_google_sheets/"}
{"prompt": "I made a little cat doodle about data analysis 🐱", "completion": "I made a little cat doodle about data analysis 🐱\nI tried explaining a data analysis concept in a fun, visual way — **for cat lovers**. 😸\nWould love to hear what you think! Any feedback or suggestions are very welcome :)", "subreddit": "r/SQL", "upvotes": 286, "date": "[PHONE]", "source": "https://www.reddit.com/r/SQL/comments/1vjo9kt/i_made_a_little_cat_doodle_about_data_analysis/"}
{"prompt": "I built the Flappy Bird game using SQL only... Now I need Therapist", "completion": "I built the Flappy Bird game using SQL only... Now I need Therapist\nhttps://reddit.com/link/1qoa7o1/video/w2zlgjn3cvfg1/player\n\n\\- All game logic, animation and rendering happens inside DB Engine using queries\n\n\\- Runs at 30 and 60 frames\n\nrepo: [https://github.com/Best2Two/SQL-FlappyBird](https://github.com/Best2Two/SQL-FlappyBird)", "subreddit": "r/SQL", "upvotes": 178, "date": "[PHONE]", "source": "https://www.reddit.com/r/SQL/comments/1qoa7o1/i_built_the_flappy_bird_game_using_sql_only_now_i/"}
{"prompt": "SQL rivals Python as the most in-demand programming language in U.S. job postings", "completion": "SQL rivals Python as the most in-demand programming language in U.S. job postings\nSource: [oxylabs.io](https://oxylabs.io/press-area/most-in-demand-programming-languages)", "subreddit": "r/SQL", "upvotes": 165, "date": "[PHONE]", "source": "https://www.reddit.com/r/SQL/comments/1u2xxk3/sql_rivals_python_as_the_most_indemand/"}
{"prompt": "What SQL concept took you the longest to actually understand, not just memorize?", "completion": "What SQL concept took you the longest to actually understand, not just memorize?\nFor those who have been working with SQL for a while, which concept took you the longest to truly understand?", "subreddit": "r/SQL", "upvotes": 142, "date": "[PHONE]", "source": "https://www.reddit.com/r/SQL/comments/1wkpzep/what_sql_concept_took_you_the_longest_to_actually/"}
{"prompt": "CSV lint plug-in for Notepad++ to validate csv files and convert to SQL insert script", "completion": "CSV lint plug-in for Notepad++ to validate csv files and convert to SQL insert script\nThe [CSV Lint plug-in for Notepad++](https://github.com/BdR76/CSVLint/) can be useful to anyone working with csv textdata and databases. I created this plugin and have [posted about it before](https://www.reddit.com/r/SQLServer/comments/13ixdh5/csv_lint_plugin_for_notepad_to_view_csv_files/)\n\nThe plug-in was previously updated with a new \"Select Columns\" dialog to easily select, delete and rearrange columns. The most recent update v0.4.9 adds support for regular expressions when validating columns.\n\nIt also adds syntax highlighting and automatically detects column datatypes. Based on the datatypes it can convert a csv file to an SQL insert script for MS-SQL, MySQL and PostgreSQL, including a `CREATE TABLE` part with correct data types for each column. This is often easier than importing it though a wizard or `BULK INSERT`\n\nIt can also validate the csv textfile beforehand, so check for technical errors like datetime formatting errors, incorrect decimal separators, missing quotes, invalid codes etc.\n\nI hope you find this plug-in useful 👍 Let me know what you think", "subreddit": "r/SQL", "upvotes": 136, "date": "[PHONE]", "source": "https://www.reddit.com/r/SQL/comments/1wt2e3y/csv_lint_plugin_for_notepad_to_validate_csv_files/"}
{"prompt": "Cursor keeps generating SQL queries like this and it's making me nervous", "completion": "Cursor keeps generating SQL queries like this and it's making me nervous\nBeen noticing a pattern in AI-generated database code that I think more people should know about. When you ask Cursor or Claude to \"add a search endpoint\" or \"filter users by name\", there's a solid chance you'll get back something like this:\n\n`const users = await db.query(\\`SELECT \\* FROM users WHERE name = '${req.query.name}'\\`);\\`\n\nThat's a textbook SQL injection. Anyone can pass `' OR '1'='1` as the name parameter and get your entire users table.\n\nThe frustrating part is the code works perfectly in testing. You search for \"john\", you get john's records. Nothing looks wrong unless you know what to look for.\n\nI've started grepping for backtick usage in database query files after any AI session:\n\n`grep -n \"query\\`|execute\\`\" src/\\`\n\nIf you see template literals inside query calls, that's the red flag. The fix is always parameterized queries:\n\n`db.query('SELECT * FROM users WHERE name = $1', [req.query.name])`\n\nWorth adding to your review checklist if you're using AI tools to build anything with a database behind it.", "subreddit": "r/SQL", "upvotes": 125, "date": "[PHONE]", "source": "https://www.reddit.com/r/SQL/comments/1s489lv/cursor_keeps_generating_sql_queries_like_this_and/"}
{"prompt": "I no longer feel like there's anything I can offer to my current organization. Anyone feel the same?", "completion": "I no longer feel like there's anything I can offer to my current organization. Anyone feel the same?\nIt's killing me. I feel so stagnant and like I'm becoming obsolete.\n\nLarge hospital system. You think I wouldn't be bored, but I am. Oracle and PL/SQL are my primary tools. We have access to Looker and can connect 3rd party tools like dbeaver, etc. for whatever.\n\nI rarely get ad-hoc requests these days and if I do, I already created a report to satisfy 'that' request as I've been here for a few years. Documents, referrals, whatever. All dashboards are basically built out, etc. For the past 2-3 years I basically come into work and sit there during the days I need to be in office. For some it's a dream, for me it's actually pretty awful. The day drags with nothing to do.\n\nOur network is locked down and while I have my own office, there are cams. I can't simply play games or anything to pass the time. I look at my queries during the day and check how I can improve them, but there's really not much I can do. Nobody ever really stops by to talk to me. I come and go like a ghost.\n\nI feel like I've gone to this place to die and I don't like it.\n\nGlad I'm employed of course and I'm sorry to those who aren't, but I'm not sure this stagnant, useless feeling is any better than the unemployed feeling.\n\nTLDR I feel like shit about my career and my position atm. Are you in the same boat? Why or why not?", "subreddit": "r/SQL", "upvotes": 123, "date": "[PHONE]", "source": "https://www.reddit.com/r/SQL/comments/1tuyk10/i_no_longer_feel_like_theres_anything_i_can_offer/"}
{"prompt": "What SQL concepts do you understand but still forget?", "completion": "What SQL concepts do you understand but still forget?\nThere are some SQL concepts I understand perfectly when I’m using them, but somehow forget when I need them again a few weeks later.\n\nFor me, **CTEs and stored procedures** are two good examples. I’ve used both, but I still end up looking up the syntax when I need them again. 😅\n\nAnyone else have a few SQL concepts like this?", "subreddit": "r/SQL", "upvotes": 113, "date": "[PHONE]", "source": "https://www.reddit.com/r/SQL/comments/1wp7yry/what_sql_concepts_do_you_understand_but_still/"}
{"prompt": "Is 40000 lines of SQL in a single file normal?", "completion": "Is 40000 lines of SQL in a single file normal?\nHeya, so my stepfather works in IT support, and the other day I was looking over his shoulder and saw that the software his company sells uses a single SQL code file that's 40000 lines long. And we're not talking three word lines here, those were 200+ characters lines. I was absolutely baffled by this, since afaik no single code file should run over 10000 lines. But I also don't do SQL.\n\nSo I asked him wtf was going on, and he told me that it was \"just like that in the industry\" and that \"I would see when I'll start working\" (I'm in uni)\n\nSo I ask all of you, is this normal? Do you see this in your job? Am I having delusions about how clean the actual tech industry is?", "subreddit": "r/SQL", "upvotes": 112, "date": "[PHONE]", "source": "https://www.reddit.com/r/SQL/comments/1v4evgx/is_40000_lines_of_sql_in_a_single_file_normal/"}
{"prompt": "Just bombed my SQL interview, not feeling great.", "completion": "Just bombed my SQL interview, not feeling great.\nHello Everyone,\n\n I just wanted to share that I just had an SQL interview for data analyst, and I completely bombed it. I chocked like crazy, and this was after days of practicing. I think I learned a valuable lesson today though, I am a very visual/hands on on type of guy. I was expecting them to give me the opportunity to write query/code or look at code related to the question, but these were all just verbal questions, that I know I could have answer if I was just allowed to write the code down or at least view it, but it was a bit overwhelming for me, especially having ADHD. It's like the questions were so long, that by the time the question ended, I already forgot what I was supposed to accomplish because I was so damn nervous and there was not code for me to review. I feel like a failure 😔. This was my first interview in 7 years, so I'm pretty rusty, but for future reference, will all interviews be in this style? No actual coding, or reviewing, or editing? They expect me to provide the whole query verbally, from  the top of my head without actually writing it on the spot? Note: this was the second follow up interview.", "subreddit": "r/SQL", "upvotes": 103, "date": "[PHONE]", "source": "https://www.reddit.com/r/SQL/comments/1vgk88x/just_bombed_my_sql_interview_not_feeling_great/"}
{"prompt": "SQL advice to yourself 5 years ago", "completion": "SQL advice to yourself 5 years ago\nQuestion to intermediate/advanced SQL users:\n\nWhats a tip that you wish someone else gave to you back when you first started using SQL? Or better said, what is something you wish you knew, and regretted it later on, when you first started learning SQL?", "subreddit": "r/SQL", "upvotes": 98, "date": "[PHONE]", "source": "https://www.reddit.com/r/SQL/comments/1r5nuad/sql_advice_to_yourself_5_years_ago/"}
{"prompt": "What SQL query optimization trick made the biggest difference for you?", "completion": "What SQL query optimization trick made the biggest difference for you?\nI've been working with SQL for a while and recently started paying more attention to query performance rather than just getting the correct result.\n\nWhat's one SQL optimization technique that made a noticeable difference for you?\n\nFor example:\n\n\\- Indexing\n\n\\- Avoiding unnecessary joins\n\n\\- Window functions\n\n\\- EXISTS vs IN\n\n\\- Reading execution plans\n\n\\- CTEs/subqueries\n\n\\- Partitioning\n\nWould be interested in hearing some real-world examples where a query went from slow to significantly faster.", "subreddit": "r/SQL", "upvotes": 97, "date": "[PHONE]", "source": "https://www.reddit.com/r/SQL/comments/1wi2f6s/what_sql_query_optimization_trick_made_the/"}
{"prompt": "You work at E-commerce. Your BOSS/CEO who just use Claude, he just created index on order.status and say index is good. It makes things faster. What do you do here as SQL BE guy?", "completion": "You work at E-commerce. Your BOSS/CEO who just use Claude, he just created index on order.status and say index is good.  It makes things faster.  What do you do here as SQL BE guy?\nAs the title says", "subreddit": "r/SQL", "upvotes": 96, "date": "[PHONE]", "source": "https://www.reddit.com/r/SQL/comments/1sn5vug/you_work_at_ecommerce_your_bossceo_who_just_use/"}
{"prompt": "Is it pronounced 's-q-l' or 'seequal'", "completion": "Is it pronounced 's-q-l' or 'seequal'\nI've worked in and around the IT environment for many years and in my experience, it's always been pronounced s-q-l although I hear some people refer to it as see-qual. Which is right?", "subreddit": "r/SQL", "upvotes": 94, "date": "[PHONE]", "source": "https://www.reddit.com/r/SQL/comments/1vobyz6/is_it_pronounced_sql_or_seequal/"}
{"prompt": "3 questions for people who use SQL in production", "completion": "3 questions for people who use SQL in production\nI wanted some feedback on some parts of a course I’ve been building since I officially have tunnel vision from doing this.\n\n1. What dirty data problems do you wish beginners had practised earlier? I already have string prices, inconsistent enums and messy joins, but I’m sure I’m missing common production failures.\n2. The grader runs each query and a reference query across several generated datasets, then compares the results using exercise specific ordering and decimal rules. Does that sound sane? What edge cases would you expect it to get wrong?\n3. I’m adding a placement test so experienced users can skip ahead. It hasn’t been tested on too many non beginners yet. What would feel like a fair bar for placing someone into joins, CTEs or window functions?\n\nIt’s a browser course wrapped in a visual novel.\n\n[https://tsunderesql.itch.io/tsunderesql](https://tsunderesql.itch.io/tsunderesql)", "subreddit": "r/SQL", "upvotes": 91, "date": "[PHONE]", "source": "https://www.reddit.com/r/SQL/comments/1vhbwyk/3_questions_for_people_who_use_sql_in_production/"}
{"prompt": "How much SQL do you still write manually?", "completion": "How much SQL do you still write manually?\nWith AI getting better at writing SQL, I’ve been wondering how much SQL analysts actually write from scratch these days.\nDo you still write most of your queries manually, or do you use AI for things like joins, CTEs, debugging, optimization, etc.?\nAnd has your use of AI actually changed how much SQL you need to know?", "subreddit": "r/SQL", "upvotes": 87, "date": "[PHONE]", "source": "https://www.reddit.com/r/SQL/comments/1wbu4hp/how_much_sql_do_you_still_write_manually/"}
{"prompt": "an unindexed WHERE burned about 85 hours of database time to update 234 rows, and never once errored", "completion": "an unindexed WHERE burned about 85 hours of database time to update 234 rows, and never once errored\nfound our single biggest database compute drain by reading pg_stat_statements sorted by total execution time, not by chasing a slow page. it was a query nobody suspected because it always returned 200 and the row count it touched was tiny.\n\na self-heal path ran an UPDATE on a 24M-row, 81GB table filtered by an external id column that was not indexed. only the internal id and one other id column had indexes. so every call full sequential-scanned the whole table, reading roughly 10GB per call, to find a handful of rows.\n\nthe numbers from pg_stat_statements: 1,674 calls averaging 166s, plus another 165 calls averaging 178s. that is about 85.7 cumulative hours of execution time, and the net effect was 234 rows changed. it never failed. it just quietly ate the database's compute budget while every other query got slower.\n\ntwo lessons I took from it. first, rank pg_stat_statements by total time, because the worst query is rarely the one that looks slow in your UI, it is the cheap-looking one called constantly against a missing index. second, when you add the index, do it with CREATE INDEX CONCURRENTLY on a hot large table. a plain CREATE INDEX takes a lock on the table and is itself an outage on something this size. after the concurrent build, the schema migration is a no-op.\n\nhow often do you all actually read pg_stat_statements? i had been relying on slow-query symptoms in dashboards and this thing never tripped a single one.", "subreddit": "r/SQL", "upvotes": 85, "date": "[PHONE]", "source": "https://www.reddit.com/r/SQL/comments/1utjjl2/an_unindexed_where_burned_about_85_hours_of/"}
{"prompt": "I've finally realized the best use case for EXISTS", "completion": "I've finally realized the best use case for EXISTS\nTextbooks never used to explain why you'd use EXISTS over a LEFT JOIN  in most cases, so I always thought it was redundant, but now I realize where it's super useful!\n\nIf you want to use test whether or not dataset a record from dataset A is found in B dataset via a complex theta join condition that might create duplicates you don't want, EXISTS is perfect! It allows you to have the test with the complex condition without creating row duplicates from the LEFT JOIN. I suppose one could do distinct after, but that's bad for performance.\n\nI am officially very pro-EXISTS clause now!", "subreddit": "r/SQL", "upvotes": 85, "date": "[PHONE]", "source": "https://www.reddit.com/r/SQL/comments/1us5j4c/ive_finally_realized_the_best_use_case_for_exists/"}
{"prompt": "Is SQL Developer jobs still alive in 2026?", "completion": "Is SQL Developer jobs still alive in 2026?\nI am in last year of my college and I am interested in SQL Developer role.\n\nIs it worthy to go for SQL developer role?", "subreddit": "r/SQL", "upvotes": 82, "date": "[PHONE]", "source": "https://www.reddit.com/r/SQL/comments/1rdhach/is_sql_developer_jobs_still_alive_in_2026/"}
{"prompt": "Even after years of SQL experience, what still trips you up the most?", "completion": "Even after years of SQL experience, what still trips you up the most?\nCurious question for people who’ve been using SQL for a long time.\n\nSyntax aside, what’s the thing that *still* causes the most headaches for you?\n\nFor me it’s always been queries that run fine but return results that feel “off” — extra rows, missing rows, weird join behavior, stuff like that.\n\nInterested to hear what others struggle with even after years of experience", "subreddit": "r/SQL", "upvotes": 76, "date": "[PHONE]", "source": "https://www.reddit.com/r/SQL/comments/1qnigbk/even_after_years_of_sql_experience_what_still/"}
{"prompt": "I made another cat doodle about data analysis", "completion": "I made another cat doodle about data analysis\nHi everyone!\n\nI’m back with another one of my data analysis cat doodles. This time, I tried to incorporate some of the feedback I received on my earlier work—especially around making the fonts and text more readable.\n\nWould be happy to hear your thoughts / feedback!", "subreddit": "r/SQL", "upvotes": 74, "date": "[PHONE]", "source": "https://www.reddit.com/r/SQL/comments/1vw116v/i_made_another_cat_doodle_about_data_analysis/"}
{"prompt": "I finally understood SQL reporting after building a full dashboard from scratch", "completion": "I finally understood SQL reporting after building a full dashboard from scratch\nI kept feeling like I “knew SQL” but still had no idea how real reporting systems\nwere actually structured like how schemas, aggregations, dashboards, etc were properly made in real-world scenarios.\n\nSo I built a small PostgreSQL + Metabase project that mirrors how internal\nreporting works at real companies:\n- transactional tables\n- reporting-style queries\n- a real dashboard (revenue, profit, top products)\n\nHonestly learned more from building this than from most tutorials.\n\nIf anyone’s interested, I wrote it up and made the project reproducible\nwith Docker so others can learn from it too.", "subreddit": "r/SQL", "upvotes": 73, "date": "[PHONE]", "source": "https://www.reddit.com/r/SQL/comments/1q41vj8/i_finally_understood_sql_reporting_after_building/"}
{"prompt": "Question: What kind of join technique is this?", "completion": "Question: What kind of join technique is this?\nHello everyone,\n\nI have been using this style of join for some months now. At first i thought this was called an implicit join but reading through the SQL guides online, it does not seem to fit the description.\n\nPlease note that i am referring only to the highlighted part. I have been doing this to isolate the INNER JOIN only to table C and not affect tables A and B. It's been working wonderfully and has been making the queries I make faster, the only catch is that when I put a WHERE clause after, everything slows down so i put the conditions on the tables themselves.\n\nThanks in advance for sharing your expertise and enlightening me on this.\n\nP.S.: where table D will have to use a condition that involves either A or B, it requires me to put it amongst the B <=> C conditions (the last line on this screen cap)", "subreddit": "r/SQL", "upvotes": 70, "date": "[PHONE]", "source": "https://www.reddit.com/r/SQL/comments/1rsurwu/question_what_kind_of_join_technique_is_this/"}
{"prompt": "I made another cat doodle about data analysis", "completion": "I made another cat doodle about data analysis\nI tried explaining a data analysis concept in a fun, visual way — for cat lovers. 😸\n\nWould love to hear what you think! Any feedback or suggestions are very welcome :)", "subreddit": "r/SQL", "upvotes": 68, "date": "[PHONE]", "source": "https://www.reddit.com/r/SQL/comments/1vlmyib/i_made_another_cat_doodle_about_data_analysis/"}
{"prompt": "inherited 340 tables in an acquisition and have two weeks to tell legal which ones hold personal data!!", "completion": "inherited 340 tables in an acquisition and have two weeks to tell legal which ones hold personal data!!\nSQL Server 2019 on prem.\n\nwe bought a smaller competitor in june. i got their warehouse in august. what i did not get is any of the three people who built it, they took the retention and left. 340 tables. there is a data dictionary of sorts, an excel file last edited in 2022, and it covers 61 of them.\n\nlegal wants a list by the end of the month of every table and column holding personal data, because the acquisition means we now hold it and the clock on that is not ours to set. they are not asking for a big project. they want a list. i cannot produce a list.\n\nwhat i've done so far:\n\nwent through it by name first. anything called email, phone, dob, name, address. got about 900 columns of the 6,000 odd. that part was easy and i don't trust it at all, because their naming is inconsistent between schemas, and i've already found one column called ref\\_4 that is full of what are very obviously mobile numbers.\n\nso then regex over sample values for the obvious formats. that found another 200 and produced a lot of false positives, order ids that look like phone numbers, that kind of thing.\n\nwhere it stops:\n\nfree text columns. there are 40 odd nvarchar(max) columns holding notes fields. some of them have names and phone numbers typed into them by humans. i have no way to scan those that i trust and no way to prove i've scanned them properly\n\n...columns where the values are personal data but not in a format anything matches. a column of 11 character strings that turn out to be their internal customer reference, which maps 1 to 1 to a person. technically identifying, does not look like anything.\n\nthe ones where i genuinely cannot tell what the column is. about 700 columns where the name tells me nothing and the values are integers or short codes. some of those could be anything. one of them might be an ethnicity code for all i know, and if it is, that is a very different conversation with legal\n\nwhat i'm asking:\n\nfor a one off audit like this, what's the actual order of operations. i've been going table by table and i think that's wrong, i think it should be column by column across the whole database sorted by something, i just don't know what the something is\n\nhas anyone had to give a legal team a defensible answer on free text fields, and what did defensible turn out to mean in practice. \"i grepped it\" does not feel like enough and i'd like to know what is\n\n..and the one i keep going round on: for the 700 columns nobody can explain, is there any approach other than sampling values and guessing. i can tell you the cardinality and the distribution. i cannot tell you what the thing is, and \"unknown\" on a list going to legal is not a great look for me.\n\nwe are not a big enough team for a governance tool and i doubt i'd get budget signed before the deadline anyway.", "subreddit": "r/SQL", "upvotes": 67, "date": "[PHONE]", "source": "https://www.reddit.com/r/SQL/comments/1wen0qa/inherited_340_tables_in_an_acquisition_and_have/"}
{"prompt": "Visualizes SQL as interactive flow diagrams, open source tool", "completion": "Visualizes SQL as interactive flow diagrams, open source tool\nI posted this in r/snowflake and I thought of sharing here as well. I created this tool to help to visualize complex SQLs as flow diagrams. Also it has lot of additional features like column lineage, CTE expansion, performance hints, and cross-file dependency analysis, etc., for multiple SQL dialects. It runs 100% on local, open source, MIT licensed.\n\n\nCurrently its available in VSCode and cursor.\n\n\nMarketplace: [https://marketplace.visualstudio.com/items?itemName=buvan.sql-crack](https://marketplace.visualstudio.com/items?itemName=buvan.sql-crack)\n\nGitHub: [https://github.com/buva7687/sql-crack](https://github.com/buva7687/sql-crack)\nCursor: [https://open-vsx.org/extension/buvan/sql-crack](https://open-vsx.org/extension/buvan/sql-crack)\n\nPlease give a try and let me know if you have any questions or feedback.", "subreddit": "r/SQL", "upvotes": 67, "date": "[PHONE]", "source": "https://www.reddit.com/r/SQL/comments/1r3b8v2/visualizes_sql_as_interactive_flow_diagrams_open/"}
{"prompt": "40,000 queries later: an update on the SQL detective game I shared here 7 weeks ago", "completion": "40,000 queries later: an update on the SQL detective game I shared here 7 weeks ago\nAbout 7 weeks ago I posted in here about [QueryCase](https://querycase.com/), where you learn SQL by working detective cases instead of grinding tutorials. This subreddit is where it started. Most of the early users came from [r/learnSQL](https://www.reddit.com/r/learnSQL/) & r/SQL and a lot of the feedback in the comments shaped what it became. So first, thanks everyone!\n\n**54 days in:**\n\n* **1,064 people** have signed up, across **87 countries**\n* **Over 40,000 queries** written and run 🚀\n* **6,188** cases, drills, exams, investigations and interview questions solved\n* Top detective is on **9,635 XP**, and 185 people are past 1,000 XP\n\n**The bit I did not see coming:** an instructor emailed asking about using it with her students. She teaches a weekend CompTIA Data+ review session, bought a handful of seats out of her own pocket, and ran the first 90 minutes of the lab on QueryCase. Then she asked for two things: a way to see how her students were getting on, and a light mode, because a dark editor projected in a lit classroom is unreadable from the back row. Both exist now. Building something for one instructor turned out to improve it for everyone.\n\n**What has been built since launch, most of it straight from feedback:**\n\n* A **Career Hub**: SQL interview questions modelled on real company loops, a rapid-fire quiz spanning SQL, statistics and A/B testing, and a guide to what each data role actually writes day to day\n* **Investigations**: open-ended timed whodunits where a live multi-table database is the crime scene, evidence unlocks as you query, and you get one accusation\n* **A progress dashboard for instructors**, so someone running a session can see how a group is doing\n* **Light mode**, for exactly the reason above\n* **Regional pricing**, after the data showed people in one country were engaging just as much as everyone else and converting ten times worse. The price had been the UK price with a currency conversion stapled on, which is not the same thing as a price that makes sense locally for everyone!\n* **A LOT** of bug fixes and improvements!!\n\n**What I would like from this post:**\n\nHalf of this list exists because someone in a thread like this or DM said \"it would be better if\". So:\n\n* What is missing that would make it genuinely useful for the way *you* learn SQL?\n* Which SQL concept did you find hardest to actually *get*, as opposed to memorise? Those make the best cases and I am always hunting for the next one\n* If you tried it early, anything that felt off, confusing or too hand-holdy?\n\nThe goal is to keep building QueryCase into something genuinely useful whether you are breaking into data, switching careers, brushing up, or you just enjoy writing SQL for the fun of it. There is plenty still on the list: **uploading your own CSVs into the sandbox** so you can query your own data, **more company interview questions**, and a lot that will come from threads like this one.\n\nIt is free to start and you do not need an account to solve the first case, so you can poke at it before deciding whether it is nonsense.\n\n[querycase.com](http://querycase.com/)", "subreddit": "r/SQL", "upvotes": 66, "date": "[PHONE]", "source": "https://www.reddit.com/r/SQL/comments/1vhtmhl/40000_queries_later_an_update_on_the_sql/"}
{"prompt": "I think I might be addicted to learning SQL?", "completion": "I think I might be addicted to learning SQL?\nHello, just wanted to say I'm a true beginner and I recently found the SQL climber website and now I'm really looking forward to my daily lessons. It's crazy because usually when I try to self-teach I get really bogged down and lazy, but something about using this site and slowly figuring things out makes me feel so satisfied.\n\nI go through a constant roller coaster of \"I'll never be able to understand this complicated mess in a million years\" to \"This is crystal clear now and just clicks\" in a couple of hours. I started practicing until I get really frustrated, and oddly if I get too confused or angry I go to sleep and the next morning it all makes sense suddenly.\n\nSo now I'm using mimo for duolingo-like lessons, and just watching a bunch of YouTube channels about data analysis. I'm fully addicted and using it to improve my work tasks (I'm a GIS analyst). I now use dbeaver and sqlite to upload CSVs from our database to clean them up, do joins, etc.\n\nNext I'm off to learning how to use github and doing full projects! Thank you to this community.", "subreddit": "r/SQL", "upvotes": 65, "date": "[PHONE]", "source": "https://www.reddit.com/r/SQL/comments/1qjw6dz/i_think_i_might_be_addicted_to_learning_sql/"}
{"prompt": "How many Sql server DBA’s are currently laid off?", "completion": "How many Sql server DBA’s are currently laid off?\nI’m wondering how many of us here in the US that are true SQL Servers dbas are currently looking for a sql job?  3-4 years ago I was getting calls weekly, now I apply and am an exact match and don’t even get a response.  Then you hear how 1000’s of ppl apply for a single job.  Just trying to see if this market is flooded now and dead.  If you’ve been layed off how long has it been?", "subreddit": "r/SQL", "upvotes": 62, "date": "[PHONE]", "source": "https://www.reddit.com/r/SQL/comments/1rh0tw6/how_many_sql_server_dbas_are_currently_laid_off/"}
{"prompt": "What was the toughest SQL interview question you have faced so far?", "completion": "What was the toughest SQL interview question you have faced so far?\nI am curious to know what SQL questions challenges people in interviews\n\nWhat was the question and what made it difficult?\n\nWould love to hear some real interview experiences🙂", "subreddit": "r/SQL", "upvotes": 62, "date": "[PHONE]", "source": "https://www.reddit.com/r/SQL/comments/1w7767s/what_was_the_toughest_sql_interview_question_you/"}
{"prompt": "SQL Protocol update: the SQL game now has a shared world and chat, so you can study with other people", "completion": "SQL Protocol update: the SQL game now has a shared world and chat, so you can study with other people\nPosted here a while ago about SQL Protocol, a browser game I built where you play a covert operative and every mission is a real SQL query against a real database. Story chapters, timed interview drills, 1v1 PvP Arena.\n\nUpdate this week:\n\n\\- The world is now shared. You see other people running missions in real time.\n\n\\- A chat panel sits at the bottom-left. GLOBAL for everyone online, MAP for whoever is in your area.\n\nSo you can ask \"why is my GROUP BY blowing up\" in chat while someone is right next to you debugging their CTE.\n\nIt is closer to a study hall now than a single-player tutorial. Same content, more people in the room.\n\nFree, desktop only, Google sign-in.\n\n[https://sqlprotocol.com](https://sqlprotocol.com)\n\nIf anyone wants to mob a chapter together this weekend, drop in. I will be in there too.", "subreddit": "r/SQL", "upvotes": 60, "date": "[PHONE]", "source": "https://www.reddit.com/r/SQL/comments/1sxfdd3/sql_protocol_update_the_sql_game_now_has_a_shared/"}
{"prompt": "SQL Query Execution Lifecycle", "completion": "SQL Query Execution Lifecycle\nDiagram illustrating the SQL query execution lifecycle, showing query submission, parsing, optimization, execution, and result delivery in a database.", "subreddit": "r/SQL", "upvotes": 59, "date": "[PHONE]", "source": "https://www.reddit.com/r/SQL/comments/1v9lixk/sql_query_execution_lifecycle/"}
{"prompt": "SQL became my all-time favorite language", "completion": "SQL became my all-time favorite language\nIt all started back in my college days when my professor introduced me to SQL and relational databases.\n\nTo this day, in my professional career, it remains my favorite language. I started with MySQL and SQL Server during college using both the terminal and SSMS.\n\nProfessionally, I spent about two years working with SQL Server, and now I am transitioning to MySQL and PostgreSQL as well. I am not pursuing a database administrator role exclusively, but rather working as a full-stack software developer. Once I master most aspects of relational databases (SQL), I plan to explore NoSQL or non-relational databases to further my passion for database management.\n\nIf I had to choose a specific profession to pursue, it would be anything dominated by SQL, such as data engineering, database administrator, or data analyst. However, given the realities of the job market, I also want to stay proficient in other powerful programming languages like Python.\n\n___\n\nDiscussion question: What are your thoughts on the career path I'm headed toward?", "subreddit": "r/SQL", "upvotes": 59, "date": "[PHONE]", "source": "https://www.reddit.com/r/SQL/comments/1wo9hkm/sql_became_my_alltime_favorite_language/"}
{"prompt": "How to use AI without becoming dumb/lazy?", "completion": "How to use AI without becoming dumb/lazy?\nI'm using it a lot for SQL code, but only now am I realizing that it's not helping me retain knowledge and I'm increasingly using it as a crutch. How do you guys do it, especially if it's something you don't know? Do you search on Google like in the old days? Or do you use AI but try to understand what it does? Many times in a hurry I'm just copying and pasting, lol, that's awful. Thanks!", "subreddit": "r/SQL", "upvotes": 58, "date": "[PHONE]", "source": "https://www.reddit.com/r/SQL/comments/1qshdmq/how_to_use_ai_without_becoming_dumblazy/"}
{"prompt": "How did you get better at reading SQL queries written by other people?", "completion": "How did you get better at reading SQL queries written by other people?\nWriting simple queries is one thing, but reading someone else’s 40-line query feels like archaeology. What actually helped you get better at that part?", "subreddit": "r/SQL", "upvotes": 57, "date": "[PHONE]", "source": "https://www.reddit.com/r/SQL/comments/1sb8tna/how_did_you_get_better_at_reading_sql_queries/"}
{"prompt": "SQL hard to master but easy to use", "completion": "SQL hard to master but easy to use\nSQL feels weird to learn at first, but once it clicks, it’s actually really simple to use.\n\nLike, the basics are just:\n\n* SELECT what you want\n* FROM where you want it\n* WHERE conditions apply\n\nThat’s it. The hard part is just getting used to thinking in terms of data tables instead of step-by-step logic.\n\nAnyone else feel like SQL is harder to *learn* than it is to actually *use*?", "subreddit": "r/SQL", "upvotes": 56, "date": "[PHONE]", "source": "https://www.reddit.com/r/SQL/comments/1t3wjjl/sql_hard_to_master_but_easy_to_use/"}
{"prompt": "how did SQL finally click for you?", "completion": "how did SQL finally click for you?\ntook a databases class last semester and passed it fine but SQL still feels weird once i get past a basic select. i can usually get something working but then i’m sitting there staring at my notes wondering why the joins actually worked.\n\nspent way too long on a lab just rearranging joins until the output looked right and that feels more like guessing than actually understanding SQL.\n\ntrying to get more reps in before classes start again. did SQL finally click for you through practice, projects or just writing queries over and over?", "subreddit": "r/SQL", "upvotes": 55, "date": "[PHONE]", "source": "https://www.reddit.com/r/SQL/comments/1vv13av/how_did_sql_finally_click_for_you/"}
{"prompt": "Database indexes finally clicked for me when I compared them to a book index", "completion": "Database indexes finally clicked for me when I compared them to a book index\nI've heard the term database index countless times, but the book analogy made it much easier to understand.\n\nImagine a 1,000-page book and you're looking for “Machine Learning.”\n\nWithout an index:\n\nPage 1 → Page 2 → Page 3 → ... → Page 847\n\nWith an index:\n\nMachine Learning → Page 847\n\nA database has a similar problem when searching through a huge table.\n\nFor example:\n\nSELECT \\\\\\* FROM students\n\nWHERE roll\\\\\\_no = 52781;\n\nWithout a suitable index, the database may need to examine many rows.\n\nWith an index, it has a structure that helps it locate the relevant row much faster.\n\nThe important part is that the index is not simply another copy of the entire table. It stores information/pointers that help locate the actual data.\n\nThere is a trade-off: indexes consume storage and need maintenance when rows are inserted, updated, or deleted.\n\nThe mental model I use now:\n\nBook index → find the page\n\nDatabase index → find the data\n\nWhat CSE concept took you way too long to understand?", "subreddit": "r/SQL", "upvotes": 54, "date": "[PHONE]", "source": "https://www.reddit.com/r/SQL/comments/1vlj8tz/database_indexes_finally_clicked_for_me_when_i/"}
{"prompt": "Pretty sure I just blew the biggest interview of my life. AMA!", "completion": "Pretty sure I just blew the biggest interview of my life. AMA!\nJust had an interview with an employer that most people would consider a dream job and am nearly 100% sure I blew it. This is the only interview I've ever studied for. I did not apply to this role. An internal recruiter reached out to me. I do have some positive takeaways as I know what weaknesses I need to shore up for future opportunities.", "subreddit": "r/SQL", "upvotes": 54, "date": "[PHONE]", "source": "https://www.reddit.com/r/SQL/comments/1tkr7c2/pretty_sure_i_just_blew_the_biggest_interview_of/"}
{"prompt": "I learned about BOMs the other day, and how strict MySQL is", "completion": "I learned about BOMs the other day, and how strict MySQL is\nWhile migrating a project from Databricks SQL to MySQL, I came to learn what BOMs (Byte Order Mark) are..\n\nWhat I thought would be a simple copy-paste, maybe change a function name to suite a different dialect, turned into extra minutes trying to figure out why a query that showed no warnings was producing Error Code: 1054.\n\nI inspected the schema, DESCRIBE'd the table. Everything looked right. Thought there might be trailing spaces till I looked more into the error code.\n\nLong story short, now I know to perform a check with:\n\nSELECT COLUMN\\_NAME, HEX(COLUMN\\_NAME)\nFROM INFORMATION\\_SCHEMA.COLUMNS\nWHERE TABLE\\_SCHEMA = DATABASE() AND\nTABLE\\_NAME = 'table\\_name';\n\nto verify that there aren't any hidden characters MySQL won't budge on that other platforms handled quietly.\n\n\n((I legit was that blonde for a few minutes))", "subreddit": "r/SQL", "upvotes": 53, "date": "[PHONE]", "source": "https://www.reddit.com/r/SQL/comments/1qa0r2s/i_learned_about_boms_the_other_day_and_how_strict/"}
{"prompt": "Is using 3-letter status codes outdated?", "completion": "Is using 3-letter status codes outdated?\nI had a pretty big debate at work over how status values should be stored in lookup tables.\n\nFor example, imagine an OrderStatus table with three columns:\nID\nStatus\nDescription\n\nMy preference is:\n1 | DRAFT      | Draft\n2 | SUBMITTED  | Submitted\n3 | INCOMPLETE | Incomplete\n\nSome people on my team prefer:\n\n1 | DRT | Draft\n2 | SUB | Submitted\n3 | INC | Incomplete\n\nMy reasoning is:\nStorage isn’t really a concern for values this small anymore.\n\nFull words are much easier to read in SQL queries, logs, APIs, and code.\n\nThey make code more self-documenting.\n\nModern IDEs and AI tools also tend to work better with descriptive values.\n\nFor example:\n\nSELECT \\*\nFROM Orders\nWHERE Status = 'INCOMPLETE';\n\nvs.\n\nSELECT \\*\nFROM Orders\nWHERE Status = 'INC';\n\nTo me, the first query is immediately understandable without needing to remember what each abbreviation means.\n\nI’m curious what other developers think. Are abbreviated status codes still considered best practice, or are full descriptive values more common nowadays?", "subreddit": "r/SQL", "upvotes": 53, "date": "[PHONE]", "source": "https://www.reddit.com/r/SQL/comments/1ujdn4a/is_using_3letter_status_codes_outdated/"}
{"prompt": "Data Analyst take home SQL interview", "completion": "Data Analyst take home SQL interview\nThis was one of the take home SQL interview i did earlier this year. I have shared for anyone who is preparing for an interview can attempt to do it. Cheers!!", "subreddit": "r/SQL", "upvotes": 50, "date": "[PHONE]", "source": "https://www.reddit.com/r/SQL/comments/1urw67e/data_analyst_take_home_sql_interview/"}
{"prompt": "How do you guys approach writing SQL when the query starts getting complicated?", "completion": "How do you guys approach writing SQL when the query starts getting complicated?\nI've been working with SQL more lately, and one thing I'm still trying to figure out is how people decide when a query is getting too complicated.\n\nSometimes I start with a simple query, then add a couple of joins, a CTE, some CASE statements, maybe a window function… and suddenly the query is 100+ lines long 😅\n\nIt still works, but at that point I'm not sure whether I should keep improving the same query or break the logic into smaller steps/tables/views.\n\nFor those of you who work with SQL regularly, what do you usually do when you reach that point?\n\nDo you have any personal rules or habits that help you keep complex SQL readable and maintainable?\n\nWould love to hear how you approach this in real projects.", "subreddit": "r/SQL", "upvotes": 50, "date": "[PHONE]", "source": "https://www.reddit.com/r/SQL/comments/1wpvoni/how_do_you_guys_approach_writing_sql_when_the/"}
{"prompt": "my queries are always way too long. How do I learn to write clean, short ones?", "completion": "my queries are always way too long. How do I learn to write clean, short ones?\nI'm intermediate — know CTEs, window functions, subqueries, etc.\nI always solve problems correctly, but my queries end up being 20+ lines with extra steps. Then I see the solution and it's 5 clean lines using one clever function.\nHow do I train myself to think in shorter SQL from the start? Any tips or resources?", "subreddit": "r/SQL", "upvotes": 49, "date": "[PHONE]", "source": "https://www.reddit.com/r/SQL/comments/1vs3rdy/my_queries_are_always_way_too_long_how_do_i_learn/"}
{"prompt": "Dealing with professionals who don’t know SQL but need it.", "completion": "Dealing with professionals who don’t know SQL but need it.\nI have started numerous saas projects in the past and there is one data-related problem that keeps coming up each and every time. We build the core team consisting of the technical founder (me), a marketing guy, a product guy, and a B2B sales rep. Up to launch everyone does their preliminary work, from building the product, to getting content in place, and building relationships with potential clients/investors.\n\nThe problem happens after launch. When the product starts onboarding users through marketing and sales, all 3 team members need to access Postgres to get data. Marketing needs to see impact of their campaigns on product adoption for example. Product and sales needs specific metrics to do their job better as well. But they cannot, because they don't know SQL.\n\nI am the only one with SQL knowledge in the team so I always am the person that has to create the query, pull the data, and send it to them. This practise happens almost daily, and I am unable to focus on my work and build the actual product. I don't blame the people in my team, they are great at what they do and SQL should not be a necessity for their roles, but it seems that without it our team cannot function.\n\nI wanted to ask if you have ever been in a similar situation and if you have used tools that enable people with no sql knowledge to interact with the database directly. We have tried building queries from LLMs but they are not sophisticated enough to get the data, and there is no way to visualize it for reporting purposes either. Most tools for this job seem too complex for users who need to review the same 3-4 metrics over and over. Also hiring business professionals with SQL knowledge is impossible nowadays. And if I do find one it is usually more of a generalist with no good experience in either role.\n\nI am looking for a simple solution from people who have adopted tools to automate this. Thanks in advance.", "subreddit": "r/SQL", "upvotes": 47, "date": "[PHONE]", "source": "https://www.reddit.com/r/SQL/comments/1r8xyjp/dealing_with_professionals_who_dont_know_sql_but/"}
{"prompt": "Need advice: Understanding complex SQL scripts written by others", "completion": "Need advice: Understanding complex SQL scripts written by others\nHi everyone,\n\nI need some advice from experienced SQL developers. I have switched from different role to data engineering 6 months back.\n\nI consider myself good/medium level at writing SQL queries and solving problems from scratch. However, I struggle when I have to understand large existing SQL scripts (300–500+ lines).\n\nI often get confused about:\n\nWhere the execution starts.How different parts of the script are connected.\n\nWhich variables, CTEs, stored procedures, or temporary tables are affecting the final output.\n\nHow to mentally trace the flow of the script.\n\nBecause of this, reading someone else's code takes me much longer than writing my own.\n\nHow did you improve this skill? Are there any techniques, exercises, books, or real-world practices that helped you become comfortable reading large SQL scripts?\n\nAlso, is this something that simply improves with experience, or is there a structured way to learn it?\n\nI'd really appreciate any advice. Thank you!", "subreddit": "r/SQL", "upvotes": 47, "date": "[PHONE]", "source": "https://www.reddit.com/r/SQL/comments/1uh5s51/need_advice_understanding_complex_sql_scripts/"}
{"prompt": "How are you automating your SQL work?", "completion": "How are you automating your SQL work?\nCurious what people are actually using to automate or speed up their SQL work.\nPython scripts? dbt? AI? Stored procedures? Some IDE/tool I’ve never heard of?\nI feel like there are probably a bunch of useful tools and workflows I’m not aware of.\nWhat are you using that actually saves you time?", "subreddit": "r/SQL", "upvotes": 47, "date": "[PHONE]", "source": "https://www.reddit.com/r/SQL/comments/1wslbjc/how_are_you_automating_your_sql_work/"}
{"prompt": "I am intimidated by SQL but I need it for future jobs.", "completion": "I am intimidated by SQL but I need it for future jobs.\nSo I’m a student and my background is not technical or STEM based at all. I am a fast learner and I know I will need SQL for future jobs, however, I’m intimidated by it because I’m not the strongest person when it comes to math. So I get seriously intimidated by it. It feels like I have to memorize hundreds of commands", "subreddit": "r/SQL", "upvotes": 46, "date": "[PHONE]", "source": "https://www.reddit.com/r/SQL/comments/1w4w2bw/i_am_intimidated_by_sql_but_i_need_it_for_future/"}
{"prompt": "[OC] A playable chess engine in pure SQL", "completion": "[OC] A playable chess engine in pure SQL\n[Quack-Mate in WASM](\n\nI wanted to see how far I could stretch a modern analytical engine out of its comfort zone, so I built a playable chess engine using pure SQL.\n\nBy \"pure SQL,\" I mean that all core chess mechanics—board representation, move generation, and evaluation—are handled entirely via declarative queries. There are no database stored procedures, no custom UDFs, and no procedural loops inside the database.\nIt runs on the DuckDB dialect mainly because I needed its native `UBIGINT` support to handle 64-bit bitboards cleanly, but the core engine operates entirely within relational constraints.\n\nI experimented with two execution modes, one SQL-only, one hybrid:\n\n**- SQL-only: a single, 550-line recursive CTE**\n\nThis directly mirrors an imperative-style recursive minimax search. It does everything in one query: move generation, evaluation, and the minimax algorithm. Because SQL is set-based, sibling nodes can't be generated conditionally during a step, which means true Alpha-Beta pruning is impossible inside a single query. As a result, this is a brutal, exhaustive search tree. It works great up to 3 plies, then it will eat whatever RAM you think you have left.\nHere is a [minimal, self-contained, recursive CTE demo](https://github.com/swingbit/quack-mate/tree/main/standalone_recursive_cte) that you can execute directly, or where you can see the full CTE (in the real engine it is generated on the fly).\n\n**- Hybrid: Batched PVS (Principal Variation Search)**\n\nThis is a playable compromise between set-based processing and depth-first chess algorithms. To break past the memory limits of the recursive CTE, I built a lightweight JavaScript orchestrator to fire smaller queries in batches. This allows the engine to handle advanced chess programming techniques (because it can update scores and statuses mid-flight) and implement real pruning across query boundaries, though not as fine-grained as an imperative engine could do. The core chess logic is still in SQL.\n\nI wrote a detailed technical breakdown of the query architecture, the trade-offs, and the optimizations here: [Quack-Mate: Pushing the Boundaries of Pure SQL Chess](https://swingbit.github.io/quackmate/)\n\n[The code](https://github.com/swingbit/quack-mate) is fully open-source.\n\nIf you want to skip the reading and just test your chess skills, you can play it in your browser (DuckDB WASM) here: [Play with Quack-Mate](https://swingbit.github.io/quack-mate/) (you can see the SQL queries being fired in real time).\n\nI'd love to get your thoughts on the query architecture, or hear how you would have approached the challenge differently.", "subreddit": "r/SQL", "upvotes": 46, "date": "[PHONE]", "source": "https://www.reddit.com/r/SQL/comments/1u7biy4/oc_a_playable_chess_engine_in_pure_sql/"}
{"prompt": "These are the relational diagrams of my company’s 16-year-old app", "completion": "These are the relational diagrams of my company’s 16-year-old app\n\nI’ve been trying to write relational queries using joins, only to realize that most of the tables aren’t actually related to each other. It looks like proper foreign key constraints were never put in place. Because of that, there’s no real referential integrity in the database, which makes writing reliable queries much harder than it should be. I now have to manually figure out how tables are logically connected, which increases the risk of mistakes and makes maintenance a lot more time-consuming. Idk whether this is normal or not for a legacy app.", "subreddit": "r/SQL", "upvotes": 46, "date": "[PHONE]", "source": "https://www.reddit.com/r/SQL/comments/1rd12ya/these_are_the_relational_diagrams_of_my_companys/"}
{"prompt": "Built a SQL mystery game - can you query the killer?", "completion": "Built a SQL mystery game - can you query the killer?\n*Solve murders. Master SQL. One query at a time.*\n\nAgatha Christie cases. Real suspects. Live SQLite database. You write the queries, you catch the killer.\n\n    SELECT s.name, a.location\n    FROM suspects s\n    JOIN alibis a ON s.suspect_id = a.suspect_id\n    WHERE a.time_from <= '23:00'\n    AND a.location != 'Cabin'\n    ORDER BY s.name;\n\n\nThat's the kind of query standing between you and the murderer.\n\nNo signup. Runs in the browser. → [querythemurder.com](https://querythemurder.com)\n\nFeedback: [[EMAIL]](mailto:[EMAIL])", "subreddit": "r/SQL", "upvotes": 43, "date": "[PHONE]", "source": "https://www.reddit.com/r/SQL/comments/1u8r1n0/built_a_sql_mystery_game_can_you_query_the_killer/"}
{"prompt": "What difference between database engines has burned you the hardest?", "completion": "What difference between database engines has burned you the hardest?\nLost way too much time debugging a query that looked completely fine, only to realize MySQL was doing case-insensitive string comparisons by default and Postgres wasn’t. Data looked like it should match. It didn’t. Because casing. Cool cool cool.\n\nWhat engine-specific behavior has wasted your time like this?", "subreddit": "r/SQL", "upvotes": 42, "date": "[PHONE]", "source": "https://www.reddit.com/r/SQL/comments/1sl5gbi/what_difference_between_database_engines_has/"}
{"prompt": "What are common SQL red flags?", "completion": "What are common SQL red flags?\nHello! interview prepping, here  wondering what are some common red flags for wrioting SQL?\n\nLike\n\nLIKE failing to index, not having trasnactions,  usign SELECT \\* instead of specific collums, etc 😃", "subreddit": "r/SQL", "upvotes": 41, "date": "[PHONE]", "source": "https://www.reddit.com/r/SQL/comments/1tiz5dv/what_are_common_sql_red_flags/"}
{"prompt": "how I learned why you shouldn't name an alias the same as the original column name", "completion": "how I learned why you shouldn't name an alias the same as the original column name\nI wrote a query last week that ran fine on Postgres and DuckDB, and hard-errored on ClickHouse and BigQuery - this sent me down a rabbit hole for most of the day.\n\nHere's what I had:\n\\`\\`\\`\nSELECT term, MAX(ranking\\_page\\_count) AS ranking\\_page\\_count\nFROM ranked\nGROUP BY term\nHAVING MAX(ranking\\_page\\_count) >= 2\n\\`\\`\\`\n\nThe CTE already had a column called ranking\\_page\\_count. I aliased MAX() of it to the same name, because why not, and then used that name again in HAVING.\n\nSo which one does HAVING actually filter by? Turns out that's a matter of opinion.\n\nIn Postgres, HAVING can’t see SELECT aliases at all. So it reads the column directly and lands on the same max anyway - no error, right answer.\n\nDuckDB does let you use aliases in HAVING, but only as a fallback, and it won't put one inside an aggregate, so this also runs. This is the one that got me, since DuckDB is where I test locally.\n\nBigQuery gives the alias priority over the column. So it read my query as MAX(MAX(...)) and gave the error \"aggregations of aggregations are not allowed\"\n\nClickHouse just swaps aliases in everywhere, so it gave code 184 illegal aggregation. it even fails when the alias isn't shadowing anything.\n\nThe thing that finally made it click for me was processing order. FROM, WHERE, GROUP BY, HAVING, then SELECT, then ORDER BY. Aliases get created in SELECT, so when HAVING runs the alias doesn't exist yet. That's why Postgres says no, and why everything else here is a vendor extension rather than four equally valid readings.\n\nORDER BY is the only clause that runs after SELECT, which is why it's the only clause where nobody argues.\n\nWhat actually worries me is that it can go completely silent. Drop the aggregate from the alias and the loud error disappears:\n\\`\\`\\`\nSELECT term, ranking\\_page\\_count \\* 10 AS ranking\\_page\\_count\nFROM ranked\nGROUP BY term, ranking\\_page\\_count\nHAVING MAX(ranking\\_page\\_count) > 4\n\\`\\`\\`\n\nPostgres and DuckDB filter on \\`ranking\\_page\\_count\\`\nBigQuery and ClickHouse filter on \\`ranking\\_page\\_count \\* 10\\`\nI get 1 row from the first two and 4 rows from the other two, and not one of them raises an error about it.\n\nThat's the version that ends up on a dashboard.\n\nok fine, I learned my lesson and won't name an aggregate after the column it aggregates...\n\nIf you work across different engines, this is your reminder to go check 🥲", "subreddit": "r/SQL", "upvotes": 41, "date": "[PHONE]", "source": "https://www.reddit.com/r/SQL/comments/1vo2gv0/how_i_learned_why_you_shouldnt_name_an_alias_the/"}
{"prompt": "Performance Win: If you filter on multiple columns, check out composite indexes. We just cut a query from 8s to 2ms.", "completion": "Performance Win: If you filter on multiple columns, check out composite indexes. We just cut a query from 8s to 2ms.\nJust wanted to share a quick performance win we had today in case anyone else is dealing with growing tables.\n\nWe have a document processing pipeline that splits large files into chunks. One of our tables recently hit about 110 million rows by surprise (whole separate story). We noticed a specific query was hanging for 8-20 seconds. It looked harmless enough:\n\n`SQL: SELECT * FROM elements WHERE document_id = '...' AND page_number > ‘...’ ORDER BY page_number`\n\nWe had a standard index on document\\_id and another one on page\\_number. Logic suggests the DB should use these indexes and then sort the results, right?\n\nAfter running `EXPLAIN (ANALYZE, BUFFERS)` we found out that it wasn't happening. The database was actually doing a full sequential scan on every query. 110 million rows… each time. Yikes.\n\nWe added a composite Index covering both the document\\_id *and* the page\\_number columns. This dropped the query time from \\~8 seconds to < 2 milliseconds.\n\n`SQL: CREATE INDEX idx_doc_page ON elements (document_id, page_number, id);`\n\nIf your table is small, Postgres/SQL is quick, and may ignore the indexes. But once you hit millions of rows the troubles start:\n\n* Don't assume two separate indexes = fast\n* If you have a `WHERE x AND y` pattern, don’t assume the individual indexes are used. Look into composite indexes (x, y) \n* Always check `EXPLAIN ANALYZE` before assuming your indexes are working.\n\nHope this saves someone else a headache!", "subreddit": "r/SQL", "upvotes": 41, "date": "[PHONE]", "source": "https://www.reddit.com/r/SQL/comments/1qj551i/performance_win_if_you_filter_on_multiple_columns/"}
{"prompt": "AI hasn't changed much for me. It still can't write a decent SQL query", "completion": "AI hasn't changed much for me. It still can't write a decent SQL query\nSometimes, I will use Gemini pro, the latest version of the model and set it to thinking or pro mode, and will ask it to do something relatively simple that I could do myself in 10 or 15 minutes. And then it'll take me 5 to 35 minutes depending on how complex the task is, to correct it repeatedly in order to get it to do what I wanted to do... So it's not actually saving me time on a regular basis.\n\nYou might think, you obviously don't know how to instruct the model or use AI, but that's not true. I've attended every Gemini training that our company has had. I've met with product managers who helped me find tune the queries, so I'm using expertly developed AI prompts that are intended to do exactly what I'm trying to do. Heck we even have a agent that reviews the AI prompt that you have and tells you if it's a good prompt or not. So the prompt is not the problem\n\nThe problem is that AI, in general, struggles with SQL because of the insane size of it. A simple SQL query that's written for a human to read, with CTEs, easily spans at least 900 lines of code. Those are the kind of queries that I've been writing. Big ETL queries. Retrieve this data from this system, connect a dates table, stitch it together with this other data, give me a final output... That's it! There's no magic.\n\nThere are some things that AI does better, for example regular expressions. There's no freaking way I can write regular expressions myself for dozens of columns, that would take me so long and programmers do the same thing. So that's something it does really well. If I need to update aliases, or clean up code, it does that pretty well. It would take me a really long time to move a bunch of columns around or switch something from a CTE to a subquery. So it does those simple little tricks pretty well.\n\nBut in general, AI is honestly worthless so far for me writing simple SQL in BigQuery. Like, what's the point of claiming that it is almost on the verge of intelligent thinking and being human-like, when you can't just throw an entire SQL query into it and have it rewrite it in a way that it actually works on the first try? That is like such an elementary thing to do in my opinion. It's not even complex. SQL has been around for so long and is honestly so simple, unless you're doing something like recursive CTEs or some crazy logic. It should not be difficult for it to do that.", "subreddit": "r/SQL", "upvotes": 41, "date": "[PHONE]", "source": "https://www.reddit.com/r/SQL/comments/1qvvjdd/ai_hasnt_changed_much_for_me_it_still_cant_write/"}
{"prompt": "Practicing window functions and keep mixing up PARTITION BY vs GROUP BY — how are they actually different?", "completion": "Practicing window functions and keep mixing up PARTITION BY vs GROUP BY — how are they actually different?\nThey both seem like they divide data into groups, so I’m having trouble understanding when I should use one instead of the other.", "subreddit": "r/SQL", "upvotes": 41, "date": "[PHONE]", "source": "https://www.reddit.com/r/SQL/comments/1wmeo56/practicing_window_functions_and_keep_mixing_up/"}
{"prompt": "How do you validate a SQL query before trusting its result?", "completion": "How do you validate a SQL query before trusting its result?\nSuppose someone gives you a complicated query with several joins and aggregations and says, “This gives the correct numbers.”\n\nWhat checks would you perform before trusting it?\n\nFor example:\nSELECT c.region, SUM(o.amount) FROM customers c JOIN orders o ON c.customer\\_id = o.customer\\_id GROUP BY c.region;\n\nWould you check row counts before/after each join, duplicate keys, NULLs, aggregates, or compare against another query?\n\nCurious what experienced SQL developers use as their checklist.", "subreddit": "r/SQL", "upvotes": 41, "date": "[PHONE]", "source": "https://www.reddit.com/r/SQL/comments/1w9081m/how_do_you_validate_a_sql_query_before_trusting/"}
{"prompt": "Has anyone imported a 1 TB JSON file into SQL Server before? Need advice!", "completion": "Has anyone imported a 1 TB JSON file into SQL Server before? Need advice!\n**Has anyone imported a 1 TB JSON file into SQL Server before? Need advice.**\n\nI work for a government agency and we need to take a huge JSON file and get it into SQL Server as usable relational data. Not just store the raw JSON, but actually turn it into tables and rows we can work with.\n\nThe problem is the file is enormous, around 1 TB, so normal methods are not really workable. It will not load into memory, and I am still trying to figure out the safest and smartest way to inspect the structure, parse it in chunks or streams, and decide how to map it into SQL Server without blowing everything up.\n\nI would appreciate any advice from people who have dealt with very large JSON imports before, especially around staging strategy, streaming vs splitting, and schema design for nested JSON.", "subreddit": "r/SQL", "upvotes": 40, "date": "[PHONE]", "source": "https://www.reddit.com/r/SQL/comments/1s1hx8w/has_anyone_imported_a_1_tb_json_file_into_sql/"}
{"prompt": "There’s no column or even combination of columns that can be considered as a pk, what would your approach be?", "completion": "There’s no column or even combination of columns that can be considered as a pk, what would your approach be?\nHey guys, it’s my first day of work as an intern and I was tasked with finding the pk but the data seems to be not proper I tried finding the pk by using a single column all the way to 4-5 combinations of columns but all I got are 85% distinct not fully distinct which can be considered as a pk, since group of columns approach is also not working I was wondering how would y’all approach this problem", "subreddit": "r/SQL", "upvotes": 39, "date": "[PHONE]", "source": "https://www.reddit.com/r/SQL/comments/1qfabaw/theres_no_column_or_even_combination_of_columns/"}
{"prompt": "isn't this is a correct way to see relationships??", "completion": "isn't this is a correct way to see relationships??\ni am trying to get funny in this su reddit by posting some memes and this meme says relationship can be done in other ways", "subreddit": "r/SQL", "upvotes": 38, "date": "[PHONE]", "source": "https://www.reddit.com/r/SQL/comments/1v439u1/isnt_this_is_a_correct_way_to_see_relationships/"}
{"prompt": "A free SQL practice tool focused on varied repetition", "completion": "A free SQL practice tool focused on varied repetition\nI’ve spent a lot of time trying all of the different free SQL practice websites and tools. They were helpful, but I really wanted a way to maximize practice through high-volume repetition, but with lots of different tables and tasks so you're constantly applying the same SQL concepts in new situations. \n\nA simple way to really master the skills and thought process of writing SQL queries in real-world scenarios.\n\nSince I couldn't quite find what I was looking for, I’m building it myself.\n\nThe structure is pretty simple:\n\n* You’re given a table schema (table name and column names) and a task\n* You write the SQL query yourself\n* Then you can see the optimal solution and a clear explanation\n\nIt’s a great way to get in 5 quick minutes of practice, or an hour-long study session.\n\nThe exercises are organized around skill levels:\n\n**Beginner**\n\n* SELECT\n* WHERE\n* ORDER BY\n* LIMIT\n* COUNT\n\n**Intermediate**\n\n* GROUP BY\n* HAVING\n* JOINs\n* Aggregations\n* Multiple conditions\n* Subqueries\n\n**Advanced**\n\n* Window functions\n* CTEs\n* Correlated subqueries\n* EXISTS\n* Multi-table JOINs\n* Nested AND/OR logic\n* Data quality / edge-case filtering\n\nThe main goal is to be able to practice the same general skills repeatedly across many different datasets and scenarios, rather than just memorizing the answers to a very limited pool of exercises.\n\nI’m curious, for anyone who uses SQL in their job, what SQL skills do you use the most day-to-day?", "subreddit": "r/SQL", "upvotes": 38, "date": "[PHONE]", "source": "https://www.reddit.com/r/SQL/comments/1ruqppd/a_free_sql_practice_tool_focused_on_varied/"}
{"prompt": "SQL JOIN questions that actually come up in Data Engineer interviews", "completion": "SQL JOIN questions that actually come up in Data Engineer interviews\nAfter going through several DE interviews, these were the JOIN\n\nscenarios that kept coming up:\n\n1. \"What's the difference between LEFT JOIN and INNER JOIN?\"\n\n  They want to hear about NULL handling, not just definitions\n\n2. \"What happens when you JOIN on a non-unique key?\"\n\n   Duplicate rows! Always check cardinality first\n\n3. \"How would you join 3+ tables efficiently?\"\n\n   Mention filtering early, joining on indexed columns\n\n4. \"When would you avoid a JOIN entirely?\"\n\n   Subqueries or window functions sometimes perform better\n\nThe key in interviews isn't just knowing the syntax\n\nit's explaining the WHY behind your JOIN choice.\n\nWhat other SQL questions have you seen in DE interviews?", "subreddit": "r/SQL", "upvotes": 37, "date": "[PHONE]", "source": "https://www.reddit.com/r/SQL/comments/1rez460/sql_join_questions_that_actually_come_up_in_data/"}
{"prompt": "Is SSMS still widely used?", "completion": "Is SSMS still widely used?\nFor a couple of decades, I’ve only ever used SSMS, am very comfortable with it.  But looking at job ads, I haven’t seen any mention of it as a skill. Everyone’s talking about snowflake, azure, fabric etc.  Is SSMS not used much anymore?  Am I outdated and need to retrain?", "subreddit": "r/SQL", "upvotes": 37, "date": "[PHONE]", "source": "https://www.reddit.com/r/SQL/comments/1qce1f2/is_ssms_still_widely_used/"}
{"prompt": "What’s a SQL anti-pattern you still see experienced developers write?", "completion": "What’s a SQL anti-pattern you still see experienced developers write?\nI’ve been learning SQL best practices, and I’m curious about the mistakes that even experienced developers sometimes make.\n\nWhat’s a SQL anti-pattern you still see in real projects? It could be related to query performance, joins, filtering, subqueries, database design, or just writing SQL that becomes difficult to maintain.\n\nWhat makes that approach problematic, and what would you normally do instead?\n\nI’d especially like to hear about examples you’ve actually encountered in production rather than just textbook mistakes.", "subreddit": "r/SQL", "upvotes": 37, "date": "[PHONE]", "source": "https://www.reddit.com/r/SQL/comments/1wnwclr/whats_a_sql_antipattern_you_still_see_experienced/"}
{"prompt": "Why might someone refuse to turn on line numbers in SSMS?", "completion": "Why might someone refuse to turn on line numbers in SSMS?\nAlmost a year ago, I started my first job out of college as a data engineer. My boss is great, incredibly smart and experienced, and I'm learning a lot from him. However, he doesn't turn on line numbers in SSMS and I can't figure out why. Having them off makes it more difficult to ask questions and point out mistakes and there doesn't seem to be any benefit to it.\n\nAbout 6 months ago I got the courage to ask him if he could turn on line numbers for my sake so that I could communicate better but he refused, not rudely or anything, he just said they didn't matter. A couple months later I asked again, out of genuine curiosity, why he doesn't have them on and he gave the same answer - \"it doesn't matter\".\n\nI feel like it does matter, so others can pair program with you more effectively and so that you can identify the location of errors thrown by SSMS, but obviously I'm not going to keep pressing the issue after already asking twice. I still want to understand, so I'm asking you all instead. Is there any valid reason to leave line numbers off?", "subreddit": "r/SQL", "upvotes": 36, "date": "[PHONE]", "source": "https://www.reddit.com/r/SQL/comments/1s2fzux/why_might_someone_refuse_to_turn_on_line_numbers/"}
{"prompt": "Entry Level Data Analytics", "completion": "Entry Level Data Analytics\nI’m a recent grad with a bachelor’s in business administration. I’ve stumbled upon some entry level data analytics positions that peaked my interest and actually pay very well for where I live. I have basically no prior SQL experience other than one computer science class I was required to take for my degree. However, I’ve been taking an intermediate SQL course on Datacamp and have really been enjoying the process. Is there anyone else who has no SQL background but found themselves working in data analytics or a similar field and are loving it? Also any advice on how to improve and look like a desirable candidate for an entry level data analytics position would be greatly appreciated.", "subreddit": "r/SQL", "upvotes": 36, "date": "[PHONE]", "source": "https://www.reddit.com/r/SQL/comments/1tzj6dy/entry_level_data_analytics/"}
{"prompt": "Episode II of SELECT * FROM LIFE;", "completion": "Episode II of SELECT * FROM LIFE;\nOne thing about me: I absolutely love making art. 🎨\n\n(You can probably tell from the slightly unnecessary number of sketch pens I own. 😅)\n\nWhenever I'm about to draw, I instinctively organize them—first by color, then by shade. It makes finding the exact pen so much easier, and I can spend more time creating instead of searching.\n\nAnd somewhere in the middle of doing that today, my data brain interrupted:\n\n\"Wait... that's basically ORDER BY.\" 😂\n\nSo this became **Episode II** of my **SELECT \\* FROM LIFE;** series.\n\nThe idea behind this series is simple: taking everyday moments and turning them into SQL doodles. I'm hoping it makes SQL feel a little less intimidating—and a little more fun.\n\nThis is also a little different from the doodles I've shared before. Most of my older ones featured cats 🐱, but I've been experimenting with different styles.\n\nWould love to hear what you think! Feedback, suggestions, or ideas for future SQL concepts are always welcome. 😊", "subreddit": "r/SQL", "upvotes": 36, "date": "[PHONE]", "source": "https://www.reddit.com/r/SQL/comments/1ungsut/episode_ii_of_select_from_life/"}
{"prompt": "joining two tables that share no key and never did, what's your actual approach", "completion": "joining two tables that share no key and never did, what's your actual approach\nPostgres 15, if that matters for the answer.\n\ngot handed a partner export to reconcile against our customer table. different ID schemes entirely, no overlap, no mapping doc, and the person who built theirs left last year.\n\nwhat I did was fuzzy match on lower(trim(email)) plus last name, then eyeball a sample of a few hundred rows. it shipped. it is also clearly bad, because I picked those two fields because they were populated, not because I had any reason to think they were good discriminators. I have no idea what my false match rate is. I just know nobody has complained.\n\nthe part that bothers me is that a bad join doesn't announce itself. a wrong customer count looks exactly like a right customer count. at least a syntax error tells you something happened.\n\nso what do people actually do here.\n\ndo you block on something cheap first to cut the comparison space down, or just run the full cross product and filter? does anyone compute a match score and hold back anything below a threshold rather than committing it? and if you do that, what threshold and did you pick it for a reason or the way I picked my fields.", "subreddit": "r/SQL", "upvotes": 36, "date": "[PHONE]", "source": "https://www.reddit.com/r/SQL/comments/1w3bvu2/joining_two_tables_that_share_no_key_and_never/"}
{"prompt": "good datasets for a project?", "completion": "good datasets for a project?\nHi, I'm looking for a dataset that has:\n\n\\- Messy, real data, with enough messiness for proper data cleaning to be needed\n\\- Enough information for actionable interesting insights\n\\- Be related to something a typical business might care about\n\nI did a project with the olist database and it was fine, but that database has been done to death. I tried contacting local small business for their data in exchange of a free data analytics report, but no luck, has someone tried that?", "subreddit": "r/SQL", "upvotes": 35, "date": "[PHONE]", "source": "https://www.reddit.com/r/SQL/comments/1w24dna/good_datasets_for_a_project/"}
{"prompt": "How do you decide between SQL and NoSQL for a new project?", "completion": "How do you decide between SQL and NoSQL for a new project?\nWhat factors do you consider first — data structure, scalability, performance, flexibility, or something else?", "subreddit": "r/SQL", "upvotes": 35, "date": "[PHONE]", "source": "https://www.reddit.com/r/SQL/comments/1wf42t2/how_do_you_decide_between_sql_and_nosql_for_a_new/"}
{"prompt": "How do you validate SQL queries in ETL pipelines?", "completion": "How do you validate SQL queries in ETL pipelines?\nWhen SQL queries are used for ETL transformations, how do you make sure the query is producing the expected results?\n\nFor example, how do you validate complex JOINs, filters, aggregations, NULL handling, duplicates, and calculated fields?\n\nDo you usually compare the results with the source data, create separate validation queries, or follow some other approach?\n\nI'd be interested to know how others handle SQL validation in real-world ETL projects.", "subreddit": "r/SQL", "upvotes": 35, "date": "[PHONE]", "source": "https://www.reddit.com/r/SQL/comments/1vypvod/how_do_you_validate_sql_queries_in_etl_pipelines/"}
{"prompt": "Real-time SQL PVP. Same prompt, same data, fastest correct query wins.", "completion": "Real-time SQL PVP. Same prompt, same data, fastest correct query wins.\nJust shipped 1v1 PvP on a SQL game I've been building.\n\nBoth players see the same prompt and schema, race to write a query that returns the correct rows. Result sets are compared, so joins vs subqueries vs CTEs all work - speed is what matters.\n\nVideo is a real match. I'll be in the comments.\n\n[SQLProtocol.com](http://SQLProtocol.com)", "subreddit": "r/SQL", "upvotes": 34, "date": "[PHONE]", "source": "https://www.reddit.com/r/SQL/comments/1t543kr/realtime_sql_pvp_same_prompt_same_data_fastest/"}
{"prompt": "Without creating any indexes, how would you speed up a ~1.5m row query?", "completion": "Without creating any indexes, how would you speed up a ~1.5m row query?\nSo our system holds ~90 days of shipped order data, and upstairs want a line level report, which in this case is ~500k orders, or ~1.5m rows when every order splits out on average to 3 rows for 3 items ordered.\n\nThe absolute most basic way I can write this, without hitting anything other than the main table and the lines table is:\n\n     SELECT h.OrderId,\n            h.Reference,\n            l.Product,\n            l.Qty\n     FROM OrderHeader h\n     JOIN Lines l\n     ON h.OrderId = l.OrderId\n     WHERE h.Customer = 'XYZ'\n     AND h.Stage = 'Shipped'\n\nThis takes about 15 seconds to run.\n\nHow would you go about doing any optimization at all on this? I've tried putting the OrderHeader references in a CTE so it filters them down before querying it, I've tried the same with the Lines table, putting WHERE EXISTS clauses in each.\n\nThe absolute best I've done is get it down to ~12 seconds, but that is within the margin of error that the DB may have just played nice when I ran it.\n\nAs soon as I start trying to pull back address data, or tracking numbers with additional joins, the query starts to get up towards a minute, and will time out if it's run in the system we have.", "subreddit": "r/SQL", "upvotes": 33, "date": "[PHONE]", "source": "https://www.reddit.com/r/SQL/comments/1rp1ocu/without_creating_any_indexes_how_would_you_speed/"}
{"prompt": "9 years into SQL... where do I go careerwise?", "completion": "9 years into SQL... where do I go careerwise?\nI learned SQL supporting a piece of software that tracked assets - I was in that role for 5 years, I tuen went in to support document control software that was also SQL based for 3 years. Fast forward to now and I'm a systems administrator for a customer of the first software company.\n\nOver that time, I've gotten pretty good - complex queries, cursors, debugging, basic query optimisation, SQL jobs, triggers, stored procs, views, a bit of PowerBI, a bit of admin, a bit of performance tweaking, small reporting database populated by complex transformations, constantly using SQL to diagnose software bugs.\n\nI enjoy this role but I feel like I have better potential- DBA roles probably want more up to date and extensive experience, I worry BI reporting's days are numbered...\n\nCan I ask if anyone has any advice for where I can go with my skillset? I love working on SQL for the problem solving, it gives me an immense sense of satisfaction.", "subreddit": "r/SQL", "upvotes": 33, "date": "[PHONE]", "source": "https://www.reddit.com/r/SQL/comments/1vh3vmw/9_years_into_sql_where_do_i_go_careerwise/"}
{"prompt": "Best SQL cerification", "completion": "Best SQL cerification\nI have solid basics in SQL,\n\nI need to pass a certification in 3-4 days,\n\nWhich one should I do?\n\nIt needs to be a credible certification.\n\nThx a lot", "subreddit": "r/SQL", "upvotes": 32, "date": "[PHONE]", "source": "https://www.reddit.com/r/SQL/comments/1wjtlyh/best_sql_cerification/"}
{"prompt": "I've been stuck on SQL self-joins for 6 months and I'm desperate, what is my mental model missing?", "completion": "I've been stuck on SQL self-joins for 6 months and I'm desperate, what is my mental model missing?\nI've been struggling with SQL self-joins for about [6 months now](https://www.reddit.com/r/SQL/comments/1o5jspc/still_confused_by_sql_selfjoin_for/) and every tutorial I've found has failed me (including AI). They all just slam the query on the screen, run it, and the video ends. Nobody actually explains the mechanics. I already feel stupid enough so please be patient with me.\n\n**What I do understand:**\n\n* Self-joins are used for tree/hierarchical structures (like employee-manager)\n* Reversing the ON condition in a *normal* join (two different tables) doesn't break anything because the table names keep the roles honest\n* In a self-join, reversing the ON condition gives silently wrong results, the query runs fine, but the data is flipped\n\n**The classic table everyone uses:**\n\n|emp\\_id | name | manager\\_id|\n|:-|:-|:-|\n|1 | Alice | NULL|\n|2 | Bob | 1|\n|3 | Carol | 1|\n|4 | Dave | 2|\n\n**Query A -- correct:**\n\n    SELECT e.name AS employee, m.name AS manager\n    FROM employees e\n    JOIN employees m ON e.manager_id = m.emp_id\n\n**Query B -- reversed, silently wrong:**\n\n    sqlSELECT e.name AS employee, m.name AS manager\n    FROM employees e\n    JOIN employees m ON m.manager_id = e.emp_id\n\n**What I've tried to understand:**\n\nI know that the ON clause is just a filter over all 16 possible row pairs (4×4). I can manually trace every pair and check which ones survive. That works I always get the right answer when I do it on paper. But I cannot keep drawing 16 rows by hand every time I write a query.\n\nPeople keep telling me things like:\n\n* *\"a manager has many employees but an employee has one manager\"* \\-- okay but how does that translate to which side of the = sign each column goes on?\n* *\"think about the direction of the relationship\"* \\-- I stop and think, a manager IS also an employee in this table, so what does direction even mean?\n* *\"the alias that holds the foreign key is the child\"* \\-- I understand foreign keys in normal joins but in a self-referencing table both aliases point to the same table so this still feels circular to me\n\nI'm not looking for an analogy. I want the actual logic. What is everyone else seeing that I'm not?\n\n[Left-self join](", "subreddit": "r/SQL", "upvotes": 32, "date": "[PHONE]", "source": "https://www.reddit.com/r/SQL/comments/1s7np7p/ive_been_stuck_on_sql_selfjoins_for_6_months_and/"}
{"prompt": "How I Learned SQL in 4 Months Coming from a Non-Technical Background", "completion": "How I Learned SQL in 4 Months Coming from a Non-Technical Background\nSharing my insights from an article I wrote back in Nov, 2022 published in Medium as I thought it may be valuable to some here.\n\nFor some background, I got hired in a tech logistics company called Upaya as a business analyst after they raised $1.5m in Series A. Since the company was growing fast, they wanted proper dashboards & better reporting for all 4 of their verticals.\n\nThey gave me a chance to explore the role as a Data Analyst which I agreed on since I saw potential in that role(especially considering pre-AI days). I had a tight time frame to provide deliverables valuable to the company and that helped me get to something tangible.\n\nThe main part of my workflow was SQL as this was integral to the dashboards we were creating as well as conducting analysis & ad-hoc reports. Looking back, the main output was a proper dashboard system custom to requirements of different departments all coded back with SQL. This helped automate much of the reporting process that happened weekly & monthly at the company.\n\nI'm not at the company anymore but my ex-manager said their still using it and have built on top of it. I'm happy with that since the company has grown big and raised $14m (among biggest startup investments in a small country like Nepal).\n\nHere is my learning experience insights:\n\n1. Start with a real, high-stakes project\n\nI would argue this was the most important thing. It forced me to not meander around as I had accountability up to the CEO and the stakes were high considering the size of the company. It really forced me to be on my A-game and be away from a passive learning mindset into one where you focus on the important. I cannot stress this more!\n\n2. Jump in at the intermediate level\n\nReal-world work uses JOINs, sub-queries, etc. so start immediately with them. By doing this, you will end up covering the basics anyways (especially with A.I. nowadays it makes more sense)\n\n3. Apply the 80/20 rule to queries\n\n20% or so of queries are used more than 80% of the time in real projects.\n\nJOINS, UNION & UNION ALL, CASE WHEN, IF, GROUP BY, ROW\\_NUMBER, LAG/LEAD are major ones. It is important to give disproportionate attention to them.\n\nAgain, if you work on an actual project, this kind of disproportion of use becomes clearer.\n\n4. Seek immediate feedback\n\nAnother important point that may not be present especially when self-learning but effective. Tech team validated query accuracy while stakeholders judged usefulness of what I was building. Looking back if that feedback loop wasn't present, I think I would probably go around in circles in many unnecessary areas.\n\nResources used (all free)\n– Book: “Business Analytics for Managers” by Gert Laursen & Jesper Thorlund\n– Courses: Datacamp Intermediate SQL, Udacity SQL for Data Analysis\n– Reference: W3Schools snippets\n\nYou can read my full 6 minute article on Medium titled \"How I Learned SQL in 4 Months Coming from a Non-Technical Background\"\n\nFun Fact: This article was shared by 5x NYT best-selling author Tim Ferriss too in his 5 Bullet Friday newsletter.", "subreddit": "r/SQL", "upvotes": 32, "date": "[PHONE]", "source": "https://www.reddit.com/r/SQL/comments/1qvb666/how_i_learned_sql_in_4_months_coming_from_a/"}
{"prompt": "When to use RIGHT JOIN instead of switching tables in Left Join", "completion": "When to use RIGHT JOIN instead of switching tables in Left Join\nHello all! I need some help with understanding the utility of Right join. I have 2 tables: Orders and Customers.  If I write Orders RIGHT JOIN Customers it returns the same results as switching tables and using left join, like Customers LEFT JOIN Orders. But when these 2 examples can give different results? Like when it is mandatory to use right join instead of just switching tables in left join?", "subreddit": "r/SQL", "upvotes": 32, "date": "[PHONE]", "source": "https://www.reddit.com/r/SQL/comments/1s3am29/when_to_use_right_join_instead_of_switching/"}
{"prompt": "How long did it take you to feel comfortable writing complex queries without any guides or references? Day 1 and I feel like a fraud", "completion": "How long did it take you to feel comfortable writing complex queries without any guides or references? Day 1 and I feel like a fraud\nSo long story short, I did a single cert and honestly struggled at this part. As irony or luck would have it I ended up recruited into a coveted position at a massive firm not realizing this was a core part of the position. To say I am overwhelmed is an understatement, I am so under qualified it’s ridiculous. I have a week before I am on my own HELP lol\n\nI know the industry, I have the math etc but wow am I overwhelmed and everything I do is logged. Do you think I can fake it until I make it?", "subreddit": "r/SQL", "upvotes": 31, "date": "[PHONE]", "source": "https://www.reddit.com/r/SQL/comments/1wg79dg/how_long_did_it_take_you_to_feel_comfortable/"}
{"prompt": "where do you actually write down what a column means", "completion": "where do you actually write down what a column means\nInherited a schema where roughly half the columns are self-explanatory and the rest are things like flag\\_3 and val\\_b. Person who built it left. There's a Confluence page describing six columns, last edited before most of them existed.\n\nI've been using COMMENT ON COLUMN because it lives with the database and can't drift into a stale wiki. Downside is nobody looks at it, it doesn't show up anywhere people work, and I've no way to know if a comment is still true after a migration.\n\nThings I'm unsure about:\n\ndoes anyone actually keep COMMENT ON up to date at scale, or does it rot the same as the wiki just less visibly\n\nif a column's meaning changes but the name doesn't, is there anything that catches that, or is it purely a review discipline problem\n\nand for the columns nobody can explain at all, do you leave them, drop them, or keep them with a comment saying unknown\n\nI've been profiling the values to guess — cardinality, null rate, distributions — which narrows it but never gets me to what the thing means.", "subreddit": "r/SQL", "upvotes": 31, "date": "[PHONE]", "source": "https://www.reddit.com/r/SQL/comments/1w4kepg/where_do_you_actually_write_down_what_a_column/"}
{"prompt": "I Turned SQL Practice Into a Mystery Game", "completion": "I Turned SQL Practice Into a Mystery Game\nI got tired of seeing people struggle with SQL tutorials, so I built a mystery game where SQL is your only tool.\n\nA mystery to solve, a few suspects, and a database full of clues: phone records, notes, transactions, key-card logs, and more.\n\nYou write queries, connect the clues, and figure out what really happened.\n\nIt uses real SQLite, with real queries, syntax errors, and challenges that gradually go from `WHERE` to `JOIN`s and subqueries.\n\nI’m the developer, happy to answer anything about how it’s built!", "subreddit": "r/SQL", "upvotes": 31, "date": "[PHONE]", "source": "https://www.reddit.com/r/SQL/comments/1wcjx97/i_turned_sql_practice_into_a_mystery_game/"}
{"prompt": "we have is_active and active_flag on the same table and they disagree on 3% of rows", "completion": "we have is_active and active_flag on the same table and they disagree on 3% of rows\nPostgres 15. Same 60 column table I've been posting about, I promise I'll stop eventually.\n\nis\\_active, boolean. active\\_flag, smallint. Both populated, both written by something, and they disagree on about 3% of rows. Nobody knows which one the app respects. I spent an afternoon on it and my best finding is that the disagreement rate has been slowly climbing since a 2021 migration, which tells me one of them stopped being maintained and not which one.\n\nThis is worse than the columns nobody can explain. flag\\_2 at least announces itself as a mystery, so nobody builds on it. These two both look like answers. Someone joined in July and spent a week working out which of three status-ish columns actually mattered, and picked wrong first.\n\nWhat I've tried: grepping for both, which gives me hits in dbt, the app repo and a commented-out block in an old migration. Checking which one the ETL writes, which is both. Asking the two people who've been here longest, who gave me different answers with the same amount of confidence.\n\nwhat I think I should do is pick the one the app actually reads at runtime, make the other a generated column off it, and let anything that disagrees break loudly. what stops me is that I can't prove which one the app reads without reading the whole app, and the reads I'm worried about aren't in the app anyway, they're in Metabase questions owned by analysts.\n\nso:\n\n* when two columns claim the same thing and disagree, is there anything better than picking one and waiting for screaming\n* has anyone made the wrong one a generated column or a view over the right one, and did it actually stop the divergence or just move it\n* more generally, do you have any way of catching a column whose meaning drifted while its name and type stayed the same. that's the failure I can't monitor for and it's the one that's actually happened here", "subreddit": "r/SQL", "upvotes": 31, "date": "[PHONE]", "source": "https://www.reddit.com/r/SQL/comments/1w9w53y/we_have_is_active_and_active_flag_on_the_same/"}
{"prompt": "How do you keep SQL queries discoverable + understandable (maybe resharable)?", "completion": "How do you keep SQL queries discoverable + understandable (maybe resharable)?\nHey guys, I’m not a data analyst, I’m in Sales Ops. I recently joined a new company and the team shared a bunch of SQL queries with me to pull data from our SQL servers (mostly supply/demand stuff).\n\nA lot of what I do is ad-hoc, but honestly many requests fall into a few repeatable groups, so the same queries get reused either as-is or with small adjustments. The problem is that over time you end up with so many of them that you forget the business logic behind each one, why certain filters/joins are there, what exactly it’s calculating and etc. Then I waste time re-reading the SQL and re-validating it again and again.\n\nI asked around internally and people in my team store sql files in OneDrive, and when they need something they run the query or link it to Excel. Data analysts use GitHub, but in ops teams nobody really uses it. Also queries are shared in Teams chat, which is super hard to search later...\n\nSo I’m wondering what people do in real life to kind of systematize that. Is there any simple workflow or tool where I can store queries in a way that’s searchable and shareable, and ideally it helps with documentation too (even something basic like auto-generating a short description of what the query does). Currently I store them in DBeaver and then just add a good naming and a description inside of a query.\n\nCurios what you think, thanks!", "subreddit": "r/SQL", "upvotes": 30, "date": "[PHONE]", "source": "https://www.reddit.com/r/SQL/comments/1r2aqju/how_do_you_keep_sql_queries_discoverable/"}
{"prompt": "Anyone else including their WHERE conditions in the JOIN conditions?", "completion": "Anyone else including their WHERE conditions in the JOIN conditions?\nI really like to put where conditions, which belong to a table into the join condition. Basic example\n\n    from table\n    left join cte\n      on cte.ID = table.ID\n      and cte.rank = 1\n\nPersonally I find this more readable especially when I have a query involving multiple joins,  because you don't have a big block of where conditions after a big block of joins and need to puzzle things together.\n\nObviously I do not put every condition in the join and I also do not put complex nested conditions in there.\n\n\nI am just wondering if I am the only who feels that this way is more logical. As far as I am aware the result of the query should be the same.", "subreddit": "r/SQL", "upvotes": 30, "date": "[PHONE]", "source": "https://www.reddit.com/r/SQL/comments/1s324tw/anyone_else_including_their_where_conditions_in/"}
{"prompt": "Why do we need abstractions over SQL?", "completion": "Why do we need abstractions over SQL?\nWhen I mean abstractions, I mainly mean OOP and ORMs.\nSQL is so simple and beautiful. Tables with rows and columns are easy to understand. And once you pick up the SQL syntax, you can pretty much achieve anything with queries. Not to mention that SQL is universal and works everywhere and anytime.\n\nThen you have the software development world... where you're asked to constantly use ORMs or map records as OOP objects. Why? ORMs are limited and do not have the flexibility of simple queries. Also mapping records as objects increases bloat, reduces performance that can hurt if the application grows and is overall not as straightforward to work with.\n\nThe only good things that ORMs are doing by default are to provide data safety and prevent SQL injection. But with some minimum and basic knowledge and discipline, you can write pure queries without having those problems. Any ideas?", "subreddit": "r/SQL", "upvotes": 30, "date": "[PHONE]", "source": "https://www.reddit.com/r/SQL/comments/1up3mtb/why_do_we_need_abstractions_over_sql/"}
{"prompt": "How important is SQL for someone trying to get into data science?", "completion": "How important is SQL for someone trying to get into data science?\nPython gets most of the attention when people talk about data science, but SQL seems to appear in a lot of actual job requirements.\n\nFor people working in data roles, how frequently do you use SQL compared with Python?\n\nWould you recommend becoming strong in SQL before getting deep into machine learning?", "subreddit": "r/SQL", "upvotes": 29, "date": "[PHONE]", "source": "https://www.reddit.com/r/SQL/comments/1vovxy8/how_important_is_sql_for_someone_trying_to_get/"}
{"prompt": "What type of SQL skills do you use as a professional data engineering(or any role where you heavily use SQL skills) everyday? Were there new sql skills you learned on the job(like Subqueries, windowing and CTEs?)", "completion": "What type of SQL skills do you use as a professional data engineering(or any role where you heavily use SQL skills) everyday? Were there new sql skills you learned on the job(like Subqueries, windowing and CTEs?)\nI really like to know more insight into how advanced my SQL skillls have to be for the average professional data engineer?", "subreddit": "r/SQL", "upvotes": 28, "date": "[PHONE]", "source": "https://www.reddit.com/r/SQL/comments/1s623c2/what_type_of_sql_skills_do_you_use_as_a/"}
{"prompt": "How should a SQL editor handle multiple statements when you click \"Run\"?", "completion": "How should a SQL editor handle multiple statements when you click \"Run\"?\nWe're building \\*\\*LibreDB Studio\\*\\*, an open-source SQL editor, and one of our volunteer contributors raised an interesting question about how multiple SQL statements should behave when using the Run action.\n\nWe're trying to understand the actual habits and expectations of SQL users before making a decision, so I'd really like to hear how you use SQL editors in practice.\n\nFor example:\n\n`CREATE TABLE test (...);`\n\n`INSERT INTO test VALUES (...);`\n\n`SELECT * FROM test;`\n\nWhat would you expect when you click \\*\\*Run\\*\\*?\n\nSome possible approaches:\n\n1. \\*\\*Run **all** statements\\*\\*\n\n   \\* \\`Run\\` executes everything in the editor.\n\n   \\* \\`Run Selection\\` can be used when you only want part of it.\n\n2. \\*\\*Run the **current** statement\\*\\*\n\n   \\* \\`Run\\` executes the statement where the cursor is.\n\n   \\* \\`Run All\\` executes the whole editor.\n\n3. \\*\\***Selection** takes priority\\*\\*\n\n   \\* No selection : current statement\n\n   \\* Selection : selected statements\n\n   \\* \\`Run All\\` is available separately.\n\n4. Other :)\n\nthere are also some interesting edge cases around this, especially when multiple statements are involved: should they run in a transaction by default, or should transaction handling always be explicit?\n\nDBeaver, DataGrip, SSMS, pgAdmin, TablePlus, Toad, PL/SQL Dev, phpMyAdmin, etc. what behavior feels most natural to you? And what behavior are you already used to?\n\nWe're continuing the discussion on GitHub as well, if you'd like to see the original question or add to the discussion:\n\n[https://github.com/orgs/libredb/discussions/776](https://github.com/orgs/libredb/discussions/776)", "subreddit": "r/SQL", "upvotes": 28, "date": "[PHONE]", "source": "https://www.reddit.com/r/SQL/comments/1wd2jcb/how_should_a_sql_editor_handle_multiple/"}
{"prompt": "How I Structured My SQL Interview Preparation (50 Problems + Real Case Studies)", "completion": "How I Structured My SQL Interview Preparation (50 Problems + Real Case Studies)\nWhen I was preparing for SQL interviews, I realized random practice wasn’t helping.\n\nSo I structured everything into:\n\n• Core SQL foundations\n• 50 coding problems (basic → advanced)\n• Window functions & ranking logic\n• 30 real business case studies\n• HR & analytics scenarios\n\nThe biggest improvement came when I stopped solving random LeetCode-style questions and started solving business-framed problems like:\n\n– Top N per group\n– Gaps & Islands\n– Revenue retention logic\n– Cohort-style analysis\n\nIf you're preparing for placements or data roles, focus on:\n\n1. Joins mastery\n2. Window functions\n3. Aggregation logic\n4. Thinking in business context", "subreddit": "r/SQL", "upvotes": 28, "date": "[PHONE]", "source": "https://www.reddit.com/r/SQL/comments/1rg0qem/how_i_structured_my_sql_interview_preparation_50/"}
{"prompt": "Struggling with LeetCode Easy after doing well on HackerRank Easy — should I move to intermediate SQL?", "completion": "Struggling with LeetCode Easy after doing well on HackerRank Easy — should I move to intermediate SQL?\n&#x200B;\n\nI wanna be straight about this because it’s getting frustrating 😭\n\nI can comfortably solve HackerRank Easy-level SQL questions, but when I try LeetCode Easy, I struggle quite a bit.\n\nI’ve seen people say that HackerRank Easy ≠ LeetCode Easy and that LeetCode can require more problem-solving/thinking even at the Easy level.\n\nSo I’m confused about what I should do next.\n\nShould I:\n\nKeep grinding LeetCode Easy until I’m more comfortable?\n\nOr is being able to solve HackerRank Easy well enough to start learning intermediate SQL concepts like subqueries and CTEs, while continuing to practice problems alongside it?\n\nBasically, I don’t want to move on too early and build gaps in my fundamentals, but I also don’t want to unnecessarily stay stuck on Easy problems when I could be learning more advanced SQL.\n\nWhat would you recommend?", "subreddit": "r/SQL", "upvotes": 27, "date": "[PHONE]", "source": "https://www.reddit.com/r/SQL/comments/1vn2wlk/struggling_with_leetcode_easy_after_doing_well_on/"}
{"prompt": "Does SQL have a LeetCode equivalent?", "completion": "Does SQL have a LeetCode equivalent?\nI'm preparing for SQL interviews and was wondering if there's a good website to practice SQL problems like we use LeetCode for DSA. Looking for interview-style questions and hands-on query practice.\n\nAny recommendations?", "subreddit": "r/SQL", "upvotes": 26, "date": "[PHONE]", "source": "https://www.reddit.com/r/SQL/comments/1ulnlr4/does_sql_have_a_leetcode_equivalent/"}
{"prompt": "In my ETL pipeline I used a Merge statement. When I asked Copilot to critique the pipeline it said Merge statements were not recommended by Microsoft. Why is this?", "completion": "In my ETL pipeline I used a Merge statement. When I asked Copilot to critique the pipeline it said Merge statements were not recommended by Microsoft. Why is this?\nOne of the critiques of the pipeline was the fact that I used Merge…instead of Insert and Update. I was wondering if anybody else ran into the same situation? Or knew why? I find that Merge TSQL statements are very easy to read and setup if I wanted to Insert then Update which basically does the same thing I would have written it that way. Is there some sort of memory buffer or leak or rowcount limitation when using Merge?  Just trying to find out why Copilot stated this.", "subreddit": "r/SQL", "upvotes": 26, "date": "[PHONE]", "source": "https://www.reddit.com/r/SQL/comments/1t2mc9m/in_my_etl_pipeline_i_used_a_merge_statement_when/"}
{"prompt": "Free 700+ SQL queries to retype", "completion": "Free 700+ SQL queries to retype\nhttps://reddit.com/link/1qodsdu/video/zkktiuyqzvfg1/player\n\nPracticing by retyping queries multiple times helped me get better with SQL. I can now explore data thoroughly during business calls and communicate correct results in the moment itself instead of sending follow-ups later.\n\nTo make that practice repeatable, I built a tool with 700+ real world SQL query examples — from simple `SELECT` to complex queries with joins, windows, partitions, and CTEs — that you type out exactly as written. No IDEs. No DBs. No complex setup. Just structured query recall.\n\nThis approach fixed a real problem for me. It may not be useful for everyone, but for people who struggle to structure valid SQL under real business conditions, I made it available for FREE here: [https://retypesql.com](https://retypesql.com/)\n\nPlease give it a try — I would love to hear your feedback.", "subreddit": "r/SQL", "upvotes": 26, "date": "[PHONE]", "source": "https://www.reddit.com/r/SQL/comments/1qodsdu/free_700_sql_queries_to_retype/"}
{"prompt": "How to get SQL certified", "completion": "How to get SQL certified\n#learning\n\nHi, I am currently a Business Analyst in a healthcare org and I feel stuck and pigeonholed in my job.\n\nCan anyone share their experience or knowledge as to the best way to get certified for someone who doesn’t have experience? I know I can download MySQL, but I am looking for a true certificate.", "subreddit": "r/SQL", "upvotes": 26, "date": "[PHONE]", "source": "https://www.reddit.com/r/SQL/comments/1q5u1lu/how_to_get_sql_certified/"}
{"prompt": "Does anyone else feel like their ERP is only half implemented?", "completion": "Does anyone else feel like their ERP is only half implemented?\nMaybe this is more common than I realize, but at work we've had NetSuite for quite a while now, and somehow we still end up using Excel for all sorts of things. Finance uses the ERP every day, but outside of that there are shared spreadsheets, little workarounds, random approvals in Teams... it's like everyone found their own way of doing things instead of using the system we already have. The funny part is that nobody really questions it anymore because \"that's just how we've always done it.\" I went down a bit of a rabbit hole on ERP optimization last weekend and read a few different articles, and it got me wondering whether this is just what naturally happens after implementation. Companies get the core modules running, everyone gets busy, and improving the rest never becomes a priority. Has anyone here actually gone back and cleaned up old processes months or years after going live? I'm curious whether it made a noticeable difference or if most teams just learn to live with the workarounds.", "subreddit": "r/SQL", "upvotes": 25, "date": "[PHONE]", "source": "https://www.reddit.com/r/SQL/comments/1v7xtk0/does_anyone_else_feel_like_their_erp_is_only_half/"}
{"prompt": "Visual foreign-key relationship tracing for SQL schemas", "completion": "Visual foreign-key relationship tracing for SQL schemas\nWhen working with large/unfamiliar SQL schemas, I’ve found that full ER diagrams are useless. I usually tend to follow foreign keys first, to understand the relations structure. The back-and-forth reading of FK relations is what helps to understand it.\n\nI’m curious whether others experience the same thing:\n\nDo ER diagrams help you understand large schemas, or do you rely more on tracing relationships while reading the code?", "subreddit": "r/SQL", "upvotes": 25, "date": "[PHONE]", "source": "https://www.reddit.com/r/SQL/comments/1r06aaj/visual_foreignkey_relationship_tracing_for_sql/"}
{"prompt": "want to make a sql project", "completion": "want to make a sql project\ni have done almost 200 sql queries , almost all the basic levels as well as advanced levels queries also (covered window functions and advanced level stuff also )  , now i want to make a good level  sql project which project i should make now ,\n\ncan anyone suggest me ????", "subreddit": "r/SQL", "upvotes": 25, "date": "[PHONE]", "source": "https://www.reddit.com/r/SQL/comments/1w7gpbl/want_to_make_a_sql_project/"}
{"prompt": "Self-taught SQL dev - Advice on leveling up from intermediate to advanced SQL", "completion": "Self-taught SQL dev - Advice on leveling up from intermediate to advanced SQL\nI am sure, you get a lot of questions like this.\n\nI’m a self‑taught SQL developer who started in marketing, moved into analytics, and eventually transitioned into SQL development. Over the past four years, I’ve worked with GROUP BY, PARTITION BY, CTEs, and window functions, and now I’m trying to level up my skills. People often tell me to learn indexing, execution plans, and performance tuning, but I’m not sure where to start. I also work in a small IT environment, so I don’t get many chances to practice advanced concepts on real projects.\n\nFor those of you who’ve been through this stage, where did you learn advanced SQL topics? And since I didn’t study SQL formally, I’m curious whether things like indexing and performance tuning are usually taught in school or mostly learned on the job.", "subreddit": "r/SQL", "upvotes": 25, "date": "[PHONE]", "source": "https://www.reddit.com/r/SQL/comments/1qexvig/selftaught_sql_dev_advice_on_leveling_up_from/"}
{"prompt": "How do you optimize SQL queries when working with millions of rows in production databases?", "completion": "How do you optimize SQL queries when working with millions of rows in production databases?\nI’m curious about the practical techniques people use in real-world systems to improve query performance and reduce execution time on large datasets.", "subreddit": "r/SQL", "upvotes": 24, "date": "[PHONE]", "source": "https://www.reddit.com/r/SQL/comments/1t6061q/how_do_you_optimize_sql_queries_when_working_with/"}
{"prompt": "SQL ( MySQL )Project ideas for Data Analyst Portfolio", "completion": "SQL ( MySQL )Project ideas for Data Analyst Portfolio\nCurrently I am doing projects in SQL i need to do projects for Data Analyst Role so Please recommend project ideas which I need to showcase for project portfolio so I need projects at advanced level .", "subreddit": "r/SQL", "upvotes": 24, "date": "[PHONE]", "source": "https://www.reddit.com/r/SQL/comments/1w0kl87/sql_mysql_project_ideas_for_data_analyst_portfolio/"}
{"prompt": "You can't see indexes, you can't see the execution plan; what are your go-to's to speed things up?", "completion": "You can't see indexes, you can't see the execution plan; what are your go-to's to speed things up?\nHypothetical, but also sort of my situation.\n\nSay you have a pdf (and experience) of the tables and columns, but you do not have SHOWPLAN permissions or any way of seeing where the choke points are. You are familiar with the db and know where the one to many, many to many and potential duplication sources are.\n\nWhat are your go-to's for optimising?\n\nOPTION(RECOMPILE) if you have a lot of DECLAREs? Not using CASTing as DATE? Not using LIKE%?\n\nI'm looking for generic things that *usually* have a performance increase, because I am fully done with adding a single JOIN and it making the query go from 1 second to 90.", "subreddit": "r/SQL", "upvotes": 24, "date": "[PHONE]", "source": "https://www.reddit.com/r/SQL/comments/1wjqa7p/you_cant_see_indexes_you_cant_see_the_execution/"}
{"prompt": "What is the difference between delete and truncate?", "completion": "What is the difference between delete and truncate?\nDelete is used to delete certain records but without where condition all records from the table will be deleted and the structure remains intact.\n\nTruncate deletes all the records from the table but the structure of the table remains intact.\n\nSo , what is the difference between them if we are using delete without where condition it performs the same function as truncate ?", "subreddit": "r/SQL", "upvotes": 24, "date": "[PHONE]", "source": "https://www.reddit.com/r/SQL/comments/1uy1ky3/what_is_the_difference_between_delete_and_truncate/"}
{"prompt": "What is the best way to handle incremental loads in sql?", "completion": "What is the best way to handle incremental loads in sql?\nIm trying to understand how ppl usually handle incremental data loads. If a source table has new, updated and deleted records, how do you identify each type?\n\nDo you normally use a timestamp, cdc,a flag column in the table, or merge? How do you handle deleted records, especially when there is no delete flag in the source?\n\nAlso, are there any common problems with using timestamps for incremental loads, like missing records or picking up the same record more than once?", "subreddit": "r/SQL", "upvotes": 24, "date": "[PHONE]", "source": "https://www.reddit.com/r/SQL/comments/1wu2aih/what_is_the_best_way_to_handle_incremental_loads/"}
{"prompt": "How do you handle schema migrations on a live production database without downtime?", "completion": "How do you handle schema migrations on a live production database without downtime?\nFor example, if you need to add or change a column, index, or constraint, how do you make the change without interrupting users?\n\nDo you follow a specific migration strategy or deployment process", "subreddit": "r/SQL", "upvotes": 24, "date": "[PHONE]", "source": "https://www.reddit.com/r/SQL/comments/1whl5jc/how_do_you_handle_schema_migrations_on_a_live/"}
{"prompt": "At what point of time do you believe that you are ready to apply for SQL Jobs ?", "completion": "At what point of time do you believe that you are ready to apply for SQL Jobs ?\nHands down, man, seriously!\n\nAt some point, after writing JOIN after JOIN, SUM, RANK, CTE, Subqueries, Window Functions, LAG, LEAD, WHERE vs HAVING, DATETIME, ORDER BY DESC...\n\nThere has to be a moment where you say:\n\n“Alright bro… enough SQL gymnastics. Let’s actually use this thing.\n\nSo what’s that point? When do you believe that you can start applying it like a real analyst.", "subreddit": "r/SQL", "upvotes": 24, "date": "[PHONE]", "source": "https://www.reddit.com/r/SQL/comments/1w6mcpi/at_what_point_of_time_do_you_believe_that_you_are/"}
{"prompt": "I created an SQL database client that runs in the terminal (dbeaver terminalized!) - Pam's Database Drawer [FOSS]", "completion": "I created an SQL database client that runs in the terminal (dbeaver terminalized!) - Pam's Database Drawer [FOSS]\nHey everyone from r/SQL!\n\nFor the past few months, I have been working on and off on Pam, a little SQL client similar to DBeaver, that runs directly on the terminal. The idea is for it to be a simple tool with some high value features most people would need from a database manager, not a huge all-in-one IDE.\n\nAs of now, we just released the first 0.1.0 beta version with the option to connect to different databases (postgres, oracle, mysql/mariadb, sqlite, sqlserver and clickhouse are supported right now), commands to save and run reusable queries, an interactive table view for the query results (with in table updates and deletes in-table), and commands to list tables and views from your database connection.\n\nIt's written in go, with the help of the great charm/bubbletea to make it look good and interactive!\n\nRepo with install and usage instructions (free and open source):\n[**https://github.com/eduardofuncao/pam**](https://github.com/eduardofuncao/pam)\n\nI’d love your feedback and suggestions, especially if you have ideas for ux/ui improvements or database edge cases to support.\n\nSo how do you like it? Do you think this would fit your workflow well? Thanks!", "subreddit": "r/SQL", "upvotes": 23, "date": "[PHONE]", "source": "https://www.reddit.com/r/SQL/comments/1qi0k3z/i_created_an_sql_database_client_that_runs_in_the/"}
{"prompt": "Has anybody done a live SQL interview?", "completion": "Has anybody done a live SQL interview?\nCurious how it works. Do you just jump on Zoom, share your screen, and answer questions in an editor? Do they give you a schema to look at? Any surprises or horror stories?", "subreddit": "r/SQL", "upvotes": 23, "date": "[PHONE]", "source": "https://www.reddit.com/r/SQL/comments/1rj6frc/has_anybody_done_a_live_sql_interview/"}
{"prompt": "Why do most SQL interview questions feel nothing like real analyst work?", "completion": "Why do most SQL interview questions feel nothing like real analyst work?\nI’ve been preparing for SQL interviews and noticed most resources focus on random queries or syntax.\n\nBut actual interview questions seem much more like business problems:\n\n\\- analysing churn / retention\n\n\\- understanding funnel drop-offs\n\n\\- balancing approval vs risk\n\nI found those way harder because it’s less about syntax and more about deciding what to measure.\n\nCurious if others found the same when preparing?", "subreddit": "r/SQL", "upvotes": 23, "date": "[PHONE]", "source": "https://www.reddit.com/r/SQL/comments/1sbh68i/why_do_most_sql_interview_questions_feel_nothing/"}
{"prompt": "Where do freelance SQL developers usually find clients?", "completion": "Where do freelance SQL developers usually find clients?\nI’m curious how people who do a lot of SQL work find freelance projects. Does most of your work come through referrals, freelance platforms, consulting relationships, or somewhere else?", "subreddit": "r/SQL", "upvotes": 23, "date": "[PHONE]", "source": "https://www.reddit.com/r/SQL/comments/1wm963z/where_do_freelance_sql_developers_usually_find/"}
{"prompt": "What’s your systematic process for optimizing a slow SQL query?", "completion": "What’s your systematic process for optimizing a slow SQL query?\nSuppose you inherit a query with multiple joins, subqueries, filters, and aggregations, and it suddenly starts taking several minutes to run.\n\nI’m curious how experienced SQL developers approach this from the first investigation to the final fix.\n\nDo you normally start with the execution plan and work from the most expensive operator? Or do you check indexes, statistics, data distribution, and join cardinality first?\n\nI’m especially interested in the **order you investigate things**. It’s easy to keep rewriting a query or adding indexes until it gets faster, but I’m curious how people systematically identify the actual bottleneck instead.", "subreddit": "r/SQL", "upvotes": 23, "date": "[PHONE]", "source": "https://www.reddit.com/r/SQL/comments/1wkrnsx/whats_your_systematic_process_for_optimizing_a/"}
{"prompt": "How can I write cleaner, more maintainable SQL?", "completion": "How can I write cleaner, more maintainable SQL?\nBasically, as the title says, I sometimes use CTEs, joins, window functions, and subqueries all in a single query.\n\nI'm able to get the job done, but I don't think my queries are very efficient, and they're definitely not something that would impress an interviewer.\n\nIs there any place where I can learn to write more readable and maintainable SQL code?", "subreddit": "r/SQL", "upvotes": 23, "date": "[PHONE]", "source": "https://www.reddit.com/r/SQL/comments/1uar5ui/how_can_i_write_cleaner_more_maintainable_sql/"}
{"prompt": "The SQL gotchas that quietly fail strong candidates in interviews", "completion": "The SQL gotchas that quietly fail strong candidates in interviews\nI've been collecting the SQL mistakes that trip up even experienced people in interviews — not syntax, but the traps where the query *looks* right and isn't. A few that catch almost everyone:\n\n1. `WHERE id NOT IN (1, 2, NULL)` returns zero rows. A NULL in the list makes every comparison UNKNOWN, so nothing passes. Use `NOT EXISTS` instead.\n2. A `LEFT JOIN` silently becomes an `INNER JOIN` the moment you add `WHERE right_table.col = 'x'` — unmatched rows are NULL there and get filtered out. Put the condition in the `ON` clause.\n3. You can't use a window function in `WHERE` (it's evaluated after `WHERE`). Wrap it in a subquery/CTE, or use `QUALIFY` if your engine has it.\n4. A join that doubles your row count and inflates a `SUM` is usually fan-out — the join key isn't unique on one side. Pre-aggregate before joining.\n5. `COUNT(*)` counts all rows; `COUNT(col)` skips NULLs, and `AVG` ignores NULLs entirely (it doesn't treat them as 0). Easy to get a \"wrong\" average and not know why.\n\nWhat others would you add? I ended up turning \\~45 of these into an Anki deck for spaced repetition because I kept re-forgetting them — happy to point to it if anyone wants it, but mostly curious what gotchas bit you in real interviews.", "subreddit": "r/SQL", "upvotes": 23, "date": "[PHONE]", "source": "https://www.reddit.com/r/SQL/comments/1txbvlr/the_sql_gotchas_that_quietly_fail_strong/"}
{"prompt": "2+ Years as a SQL Server DBA, But Every Mid-Level Job Wants 5+ Years. What Would You Do?", "completion": "2+ Years as a SQL Server DBA, But Every Mid-Level Job Wants 5+ Years. What Would You Do?\nHi everyone,\n\nI'm a Microsoft SQL Server DBA with a little over **2 years of professional experience**, currently working at one of the largest banks in Georgia (Tbilisi).\n\nMy goal is to move from a Junior DBA role into a Mid-Level DBA position.\n\nThe challenge is that SQL Server DBA opportunities in my country are extremely limited. There are only a few openings each year, and almost all of them require **5-10+ years of production experience**.\n\nI still apply whenever I can, but I often reach the final interview stages and then get rejected because I'm missing the level of production experience they're looking for.\n\nInstead of giving up, I've been investing a lot of my personal time in building my own Azure home lab to learn technologies that I don't have the opportunity to use every day at work.\n\nSo far I've built and worked with:\n\n* Microsoft SQL Server\n* Windows Server & Active Directory\n* Windows Failover Clustering\n* Always On Availability Groups\n* SQL Server Listener\n* Azure Internal Load Balancer\n* Kerberos & SPNs\n* SQL Server backups & restores\n* Execution Plans\n* Indexing (Clustered / Nonclustered / Covering Indexes)\n* Performance Tuning (currently studying)\n* T-SQL\n\nI'm continuing to study topics such as Query Store, Extended Events, Wait Statistics, Blocking, Deadlocks, Replication and Log Shipping.\n\nI know I'm still missing some production experience, but I'm doing everything I can to close that gap by building practical labs and continuously improving my skills.\n\n**I have a few questions for the community:**\n\n1. **Do you know any companies that hire remote Microsoft SQL Server DBAs (Junior or Mid-Level)?**\n2. **Are there any websites or platforms where I can practice real DBA tasks and production-like scenarios?**\n3. **If you were in my position, what would you focus on next to become competitive for Mid-Level SQL Server DBA roles?**\n\nI'm based in **Tbilisi, Georgia**, but I'm open to **remote opportunities** and flexible regarding compensation if it means joining a strong team, gaining real production experience, and continuing to grow as a DBA.\n\nIf anyone knows about remote SQL Server DBA openings or has any advice, I'd be very grateful.\n\nThank you very much for your time.", "subreddit": "r/SQL", "upvotes": 22, "date": "[PHONE]", "source": "https://www.reddit.com/r/SQL/comments/1ux2w0w/2_years_as_a_sql_server_dba_but_every_midlevel/"}
{"prompt": "What Kind of SQL Should I Master for Real Industry Work?", "completion": "What Kind of SQL Should I Master for Real Industry Work?\nI understand why SQL is important for placements, and I've already studied SQL and PL/SQL in college. During interviews, companies usually ask SQL queries involving joins, subqueries, window functions, aggregations, and other common topics.\n\nHowever, I'm curious about what happens after getting a job.\n\nFor software engineers, data engineers, backend developers, or other tech roles:\n\nHow is SQL actually used in day-to-day work?\n\nWhat kinds of SQL queries do you write in a real project?\n\nIs it mostly CRUD operations, or do you regularly write complex queries with CTEs, window functions, stored procedures, triggers, and query optimization?\n\nHow much database design and performance tuning is expected from a fresher?\n\nWhich SQL concepts should I focus on if I want to be productive in an actual job rather than just clear placement interviews?\n\nI'd appreciate examples from your own work experience.", "subreddit": "r/SQL", "upvotes": 22, "date": "[PHONE]", "source": "https://www.reddit.com/r/SQL/comments/1uqhepd/what_kind_of_sql_should_i_master_for_real/"}
{"prompt": "How to get table relationships?", "completion": "How to get table relationships?\nI have 4000 tables. But I have no idea how each table is related to each other.\n\nI'm using SSMS. ERP and DBMS were setup by another company, that company does not have any integration docs.\n\nRight now I'm asked to create a reports out of 5 tables, some do not have primary key, foreign keys or unique composite key with the other tables..... Which means it's related to some other tables then to my 5.\n\nI have 2 other reports with the same problem.\n\nI've tried object explorer - \"Relationships\".... Nice and empty. I also tried \"design\" to look for relationships. I found a lot of Index.... I think they contain composite keys, but I have no idea to which tables.\n\nAny idea how I can find out which tables are related, other than using the index.", "subreddit": "r/SQL", "upvotes": 22, "date": "[PHONE]", "source": "https://www.reddit.com/r/SQL/comments/1s2anrh/how_to_get_table_relationships/"}
{"prompt": "Using CTEs for aliases", "completion": "Using CTEs for aliases\nI need to define a bunch of aliases for selections (and they need to work in function calls and WHERE clauses etc.)\n\nI am thinking I should wrap the query in a CTE. My question is about execution efficiency. I understand that the CTE does not execute (it's SELECT statements) until it is referenced in the query it is wrapped around.\n\nBut if my CTE clauses are like:\n\nWITH myAliases (alias\\_1) AS (select col\\_1 FROM tab)\ndoes that mean that when referenced, the entire table column for alias\\_1 will actually be brought in?\n\nI don't think I want that -- the reference to alias\\_1 in the actual query is liable to have a\nWHERE alias\\_1 > 69\nclause in it.\n\nI am hoping that the CTE would effectively be more like a macro. I do not know the magic of how CTEs work: what rewriting happens in the engine.\n\nAssuming that works the way I wish, my second question is whether to use a single CTE to alias all the columns; or should I have a CTE for each column and plug all those CTE names into the FROM of the real query?\n\nWITH aliases (a,b,c) (select a,b,c...)\nversus\nWITH (alias\\_1) ... (alias\\_2)....\nSELECT a,b,c FROM alias\\_1, alias\\_2\n\nIf this is all a bad idea, is there a better way to accomplish what I want?\n\nThank You!", "subreddit": "r/SQL", "upvotes": 22, "date": "[PHONE]", "source": "https://www.reddit.com/r/SQL/comments/1q3sube/using_ctes_for_aliases/"}
{"prompt": "Oracle doesn't care if you use the same alias for different tables", "completion": "Oracle doesn't care if you use the same alias for different tables\nSo I stumbled upon something weird in Oracle. If you assign the same alias to two different tables in FROM the query just runs. No error.\n\nHere's what I mean:\n\nsql\n\n    SELECT *\n    FROM dual a\n    LEFT JOIN dual a ON a.dummy = a.dummy;\n\nTwo tables, both called `a`. Works fine.\n\nYou can even do three:\n\nsql\n\n    SELECT *\n    FROM dual a\n    JOIN dual a ON a.dummy = a.dummy\n    LEFT JOIN dual a ON a.dummy = a.dummy;\n\nStill works. I was sure this should throw an error, but nope.\n\n# So when does it actually break?\n\nThe trick is it only works with ANSI JOIN syntax, and only when the duplicate alias is used inside ON clauses.\n\nThe moment you reference it in SELECT, WHERE, etc Oracle finally wakes up:\n\nsql\n\n    -- ORA-00918: column ambiguously defined\n    SELECT a.*\n    FROM dual a\n    JOIN dual a ON a.dummy = a.dummy;\n\nAnd with old-school Oracle comma syntax it always fails:\n\nsql\n\n    -- ORA-00918: column ambiguously defined\n    SELECT *\n    FROM dual a, dual a\n    WHERE a.dummy = a.dummy;\n\n# Why does this even work?\n\nLooks like Oracle processes ANSI JOINs step by step. Each ON clause lives in its own little scope and resolves aliases locally. It doesn't check if the alias is globally unique at that stage. But once it gets to SELECT or WHERE it sees the full table list and goes \"wait, which `a` do you mean?\"\n\n# The fun part - which alias wins?\n\nsql\n\n    SELECT *\n    FROM dual a\n    JOIN (SELECT 'Z' dummy FROM dual) a ON a.dummy = a.dummy\n    LEFT JOIN (SELECT 'Y' dummy FROM dual) a ON a.dummy = a.dummy;\n\nResult:\n\n    D   D   D\n    -   -   -\n    Z   Z   Y\n\nSo in each ON, the alias resolves to the left side of that particular join. But honestly the behavior is unpredictable. Your query might silently pull data from the wrong table, and you'd never know. Especially dangerous in big queries with dozens of joins where a copy-pasted alias can easily slip through.\n\n# What the SQL standard says\n\nANSI/ISO 9075 is clear - table aliases within a single FROM must be unique. PostgreSQL, SQL Server, MySQL all correctly reject this. Oracle just lets you shoot yourself in the foot.\n\n# Version info\n\nFrom what I found online, this bug appeared somewhere between [IP] and [IP] patches. I tested on [PHONE] - confirmed, it's there.\n\nIf anyone has access to 12.2, 19c or 23ai - would be curious to know if it's still reproducible.", "subreddit": "r/SQL", "upvotes": 22, "date": "[PHONE]", "source": "https://www.reddit.com/r/SQL/comments/1skk97e/oracle_doesnt_care_if_you_use_the_same_alias_for/"}
{"prompt": "how do you prove a column is safe to drop, given you can only ever prove the opposite", "completion": "how do you prove a column is safe to drop, given you can only ever prove the opposite\nPostgres 15, Snowflake downstream.\n\nwe've got a table with 60-odd columns and I'd guess 20 are dead. nothing in any dbt model, nothing in the app repo, nobody has mentioned them.\n\nall of that is evidence of absence. I can prove a column IS used. one grep hit and I'm done. I can't prove one isn't. the query that reads it might be a saved Metabase question, a Retool app, a cron, a notebook on someone's laptop, or a process that only runs in January. finding nothing means I looked where I know to look.\n\nturned on pg\\_stat\\_statements and watched for a month. that catches whatever ran in that month and tells me nothing about January. renaming instead of dropping and waiting for screaming works, but it's shipping a landmine and hoping the person who steps on it works here.\n\nhere's where it actually stalled though. the usage question is at least measurable if I'm patient. what I can't get at is the other pile: about a dozen columns where I can see they're populated, I can see something writes to them, and nobody alive can tell me what they hold. flag\\_2, four-character codes with 11 distinct values, three separate integer columns bounded 0 to 4. I wrote two of these myself in 2023 and I can't tell you what one of them is either.\n\nI've been profiling the values to guess. cardinality, null rate, distribution, sample values, what changes when. that narrows it a lot. it has never once got me to what the thing actually means. a column of 0-4 integers with no nulls is a rating or a tier or a retry counter and the values look identical in all three cases.\n\nso two questions, and the second is the one I care about.\n\nis there a point where you accept you've looked hard enough on usage, a fixed window or a silence rule, or do you just never drop anything, which is what we're doing by default.\n\nand for the ones nobody can explain: is working out what a column means from its values alone still a human job, or is anyone doing it any other way? I've read that some of the tabular model work goes at this, reading the values rather than the header, but everything I've actually tried in practice leans on the column name, which is the one thing I don't have.\n\nworth saying I'd have shipped my profiling guesses as documentation if someone hadn't asked me how I knew. I didn't know. I had a distribution and a hunch.", "subreddit": "r/SQL", "upvotes": 22, "date": "[PHONE]", "source": "https://www.reddit.com/r/SQL/comments/1w71e3l/how_do_you_prove_a_column_is_safe_to_drop_given/"}
{"prompt": "I want to get better for Data Engineer / Data Scientist positions", "completion": "I want to get better for Data Engineer / Data Scientist positions\nHello everyone,\n\nSo I've studied SQL in University, Inwould consider myself somewhat good + I like it. I've done  basic courses and some advanced. I manage to do some easy interview questions... but I want to get better.\n\nCan you recomend me some resources where I can expand my knowledge:\n\n\\* A lot of problems to solve so I can see typical templates.\n\nWith chatGPT even if I'm stuck I can get the idea. But yes, all tips are welcomed. Thank you :)", "subreddit": "r/SQL", "upvotes": 22, "date": "[PHONE]", "source": "https://www.reddit.com/r/SQL/comments/1vi23lq/i_want_to_get_better_for_data_engineer_data/"}
{"prompt": "What’s your process for validating data after ETL jobs?", "completion": "What’s your process for validating data after ETL jobs?\nCurious how others handle this —\n\nAfter running a pipeline (like MySQL → BigQuery / Snowflake), how do you make sure the data is actually correct?\n\nDo you rely on:\n\n- row count checks?\n- schema comparison?\n- custom scripts?\n\nOr is there a better way?\n\nTrying to understand real-world practices and pain points here.\n\nNot promoting anything — just learning.", "subreddit": "r/SQL", "upvotes": 21, "date": "[PHONE]", "source": "https://www.reddit.com/r/SQL/comments/1s4fyme/whats_your_process_for_validating_data_after_etl/"}
{"prompt": "I built a SQL game where the PvP mode validates queries server-side so the client never sees the solution", "completion": "I built a SQL game where the PvP mode validates queries server-side so the client never sees the solution\nBuilt SQL Protocol (https://sqlprotocol.com), a browser game\n\nwhere every mission is a real Postgres query. Free, desktop.\n\n1v1 Arena pits two players on the same case. Expected result\n\nstays server-side, never sent to the client. Server runs both\n\nqueries and compares row sets.\n\nKnown weak spots in the validator:\n\n\\- GROUP BY with ambiguous aggregates\n\n\\- Column-order edge cases after normalization\n\n\\- Cases I forgot to flag as order-sensitive\n\nTry to break it. If you find two equivalent queries that\n\ndisagree, I'll fix it today and reply with the commit.\n\nAlso curious: are chapters 1-3 too easy for this crowd?\n\nGoogle sign-in only right now (working on guest mode). Not\n\nopen source while PvP is live.", "subreddit": "r/SQL", "upvotes": 21, "date": "[PHONE]", "source": "https://www.reddit.com/r/SQL/comments/1su92ju/i_built_a_sql_game_where_the_pvp_mode_validates/"}
{"prompt": "SQL Data Cleaning Every Analyst Should Know", "completion": "SQL Data Cleaning Every Analyst Should Know\nTake a dirty business orders dataset and turn it into a clean SQL reporting view. In this tutorial we’ll remove duplicate rows, standardize DMA regions, clean messy text fields, fix invalid dates, and build a reusable SQL cleaning workflow", "subreddit": "r/SQL", "upvotes": 21, "date": "[PHONE]", "source": "https://www.reddit.com/r/SQL/comments/1tnxqnn/sql_data_cleaning_every_analyst_should_know/"}
{"prompt": "I built my first-ever SQL portfolio project. I don't know if it's fine or crap. Comments?", "completion": "I built my first-ever SQL portfolio project. I don't know if it's fine or crap. Comments?\n**Context:** I am a beginner in SQL. As a desperate unemployed graduate, I am targeting entry level data analytics and related roles. I realized that SQL is one of the core skills for such roles. Following this, I took a course in 'SQL and DBMS with Python' and once I was confident in querying skills, I decided to build an introductory project.\n\nThe sole purpose of the project is to demonstrate my understanding of SQL and querying skills to a potential employer. Do you think the project and its presentation conveys that message? Is it convincing enough?\n\n**Request:** Generally, as someone with SQL experience I would love to know your impression of my project :)\n\nAny and all recommendations/tips/guidance are much much welcome and appreciated!\n\nPortfolio: [https://github.com/moztarib/data-analytics-sql](https://github.com/moztarib/data-analytics-sql)\n\nI am using SQLite DBMS.", "subreddit": "r/SQL", "upvotes": 21, "date": "[PHONE]", "source": "https://www.reddit.com/r/SQL/comments/1s2qx6x/i_built_my_firstever_sql_portfolio_project_i_dont/"}
{"prompt": "What topics should I add to make my MySQL course truly complete? (100+ SQL Problems Already Covered)", "completion": "What topics should I add to make my MySQL course truly complete? (100+ SQL Problems Already Covered)\nHi everyone,\n\nI'm currently creating a **complete MySQL course** focused on **learning through real interview-style problems** rather than just theory.\n\nSo far, I've covered **100+ SQL problems** using a well-designed dataset that includes topics ranging from beginner to advanced, such as:\n\n* Filtering (WHERE)\n* GROUP BY, HAVING & Aggregate Functions\n* Joins\n* Subqueries\n* CTEs\n* Window Functions\n* CASE, String & Date Functions\n* UNION & UNION ALL\n* Views\n* Stored Procedures\n* Triggers\n* Recursive CTE\n* Indexing\n* And many real-world interview questions\n\nIf you'd like to check out the course, here's the documentation and YouTube playlist:\n\n📄 **Documentation:** [https://github.com/vivekpandey76/Mysql-course](https://github.com/vivekpandey76/Mysql-course)\n🎥 **YouTube Playlist:** [https://youtube.openinapp.co/youtubseries](https://youtube.openinapp.co/youtubseries)\n\nI'd really appreciate your feedback.\n\n**What topics do you think are still missing that every MySQL developer should know?**\n\nI'm looking for suggestions that would help make this course one of the most comprehensive resources for mastering MySQL—from beginner concepts to advanced interview preparation and real-world SQL.\n\nWhether it's:\n\n* Advanced SQL concepts\n* Performance tuning\n* Database design\n* Transactions & locking\n* Query optimization\n* Lesser-known MySQL features\n* Common interview questions\n* Real-world scenarios\n\n...or anything else you think is important, I'd love to hear your suggestions.\n\nThanks in advance! 😊", "subreddit": "r/SQL", "upvotes": 21, "date": "[PHONE]", "source": "https://www.reddit.com/r/SQL/comments/1uys4eu/what_topics_should_i_add_to_make_my_mysql_course/"}
{"prompt": "Fairly new to SQL. Whats some long SQL as far as lines of code?", "completion": "Fairly new to SQL. Whats some long SQL as far as lines of code?\nSo i normally write brief SQL. Normally 30 or so lines cover what i need to query. However IT recently gave me the SQL and access to the tables behind a PowerBuilder report and it was close to 300 lines of code. Lots of outer joins and a bunch of CASE logic. So just curious how wild does SQL usually get in the business world?", "subreddit": "r/SQL", "upvotes": 21, "date": "[PHONE]", "source": "https://www.reddit.com/r/SQL/comments/1qfhg62/fairly_new_to_sql_whats_some_long_sql_as_far_as/"}
{"prompt": "I Finally Completed MySQL from Basics to Advanced — Now Starting 50+ Interview SQL Questions", "completion": "I Finally Completed MySQL from Basics to Advanced — Now Starting 50+ Interview SQL Questions\nMysql Notes of the series: [https://github.com/vivekpandey76/Mysql-course](https://github.com/vivekpandey76/Mysql-course)", "subreddit": "r/SQL", "upvotes": 21, "date": "[PHONE]", "source": "https://www.reddit.com/r/SQL/comments/1upnehx/i_finally_completed_mysql_from_basics_to_advanced/"}
{"prompt": "I tried a flipbook-style Doodle on Data Analysis concept", "completion": "I tried a flipbook-style Doodle on Data Analysis concept\nI’ve been making these little **Data Analysis 101** doodles for cat people, and for this one I tried something different — a **flipbook-style format**.\n\nInstead of putting everything into one busy infographic, I’ve broken the story into separate scenes, so each one focuses on a single idea and hopefully doesn’t demand too much attention at once.\n\nI’ve also incorporated feedback I received on my previous posts, especially around making the visuals easier to follow.\n\nThis one is about **what to do when you join a data project that’s already in motion.**\n\nWould be happy to hear your feedback on this!", "subreddit": "r/SQL", "upvotes": 21, "date": "[PHONE]", "source": "https://www.reddit.com/r/SQL/comments/1vp8ap2/i_tried_a_flipbookstyle_doodle_on_data_analysis/"}
{"prompt": "People-focussed SQL/data jobs", "completion": "People-focussed SQL/data jobs\nIf you wanted to quit being a full time data engineer, and do a more people-focussed role, what sort of job options are out there that which benefit from strong SQL/database knowledge?  Other than sales. Eww, sales.", "subreddit": "r/SQL", "upvotes": 20, "date": "[PHONE]", "source": "https://www.reddit.com/r/SQL/comments/1qdpoev/peoplefocussed_sqldata_jobs/"}
{"prompt": "Conceptual question: Struggling to understand the practical difference between Clustered and Non-Clustered Indexes in SQL Server", "completion": "Conceptual question: Struggling to understand the practical difference between Clustered and Non-Clustered Indexes in SQL Server\nHi everyone, I'm currently studying SQL Server and struggling to grasp the practical use cases for different indexes.\n\nI know the textbook definitions (clustered = physical order, non-clustered = stored separately). But in a real-world database, when would you actually choose a non-clustered index?\n\nFor example, if I have a massive \"Customers\" table and frequently search by `LastName` instead of the `CustomerID` primary key, why shouldn't I just make `LastName` The clustered index to speed up those searches?", "subreddit": "r/SQL", "upvotes": 20, "date": "[PHONE]", "source": "https://www.reddit.com/r/SQL/comments/1ra3f6r/conceptual_question_struggling_to_understand_the/"}
{"prompt": "Update on the 340 inherited tables: legal has the list here's what actually worked", "completion": "Update on the 340 inherited tables: legal has the list here's what actually worked\nSQL Server 2019 on prem. Follow up to my post from last week about inheriting 340 tables and having two weeks to tell legal which ones hold personal data. Sent legal the list on Friday. Most of what got me there came out of the replies so heres the short version\n\nWhat worked;--\n\nAsked legal what the list was actually for. Shouldve been day one. They wanted fields intended to hold personal data as tier 1 and everything else on a residual risk list with an owner and a review date. I'd spent a week building a forensic audit noone asked for\n\nOne sheet one flag, column by column instead of table by table. Profiled all \\~6,000 columns once and pulled distinct counts from sys.dm\\_db\\_stats\\_properties instead of running COUNT(DISTINCT) six thousand times. Distinct close to rowcount went into an identifier queue which is where the 11 char customer ref showed up along with a few I'd missed. Cheap regex on 10% of rows first then slower passes only on whats left. Stop on first hit.\n\nthe 700 unknowns were mostly a people problem. Printed the top 20 values of each one and sat with two people from support. Where is this on your screen, what do you type here. They placed about 210 in forty minutes. ref\\_4 was the mobile field from their old CRM, migrated in 2021 and never renamed. The rest came from views and procs, joins inferred from value overlap and planting a ZZQX marker through the UI and the nightly import then tracing where it landed. The one I was worried was an ethnicity code was a delivery zone.\n\nFree text I just flagged all 40 by default then ran a local 8B over a restored copy of the databse on an isolated box to see which ones actually had names and numbers in them. Fine on text useless on short codes. At the end I hand checked a random 200 columns, 6 disagreemnts all false positives. Method plus that number is what legal accepted as defensible numbers. 700 unexplained at the start and 31 at the end which is under the 40 I said I could live with. 130 of my original 900 name matches were wrong. 2 IP columns I'd filed under logging. The 9k scanned PDFs have filenames like surname\\_dob.pdf so thats its own job now.\n\nWhat Im asking now is that--\n\ntools. I did this with a notebook a spreadsheet and an idle 4090. Is there anything that does column level classification on prem against SQL Server with nothing leaving the network and without a year contract? I have to redo this when it migrates next year and keeping it from happening again. Someone mentioned a weekly job asking owners to classify new columns that nobody answers. How do you get people to classify a column when its created and not two years later? And if youve been on the buying side what do you get out of the people who built it before they take the retention and leave?", "subreddit": "r/SQL", "upvotes": 20, "date": "[PHONE]", "source": "https://www.reddit.com/r/SQL/comments/1wmjsmy/update_on_the_340_inherited_tables_legal_has_the/"}
{"prompt": "Cross-source SQL joins without a data warehouse - how do you handle this?", "completion": "Cross-source SQL joins without a data warehouse - how do you handle this?\n\nSay you've got data in Postgres, a CSV from a client, and some Parquet files on S3. You need to join them for a one-off analysis. What's your workflow?\n\nI built a desktop tool around DuckDB that handles this natively - curious what approaches others use. ETL everything into one place? dbt? Something else?", "subreddit": "r/SQL", "upvotes": 20, "date": "[PHONE]", "source": "https://www.reddit.com/r/SQL/comments/1simknq/crosssource_sql_joins_without_a_data_warehouse/"}
{"prompt": "What are some obvious reasons a 1:1 join would work better as LEFT than INNER?", "completion": "What are some obvious reasons a 1:1 join would work better as LEFT than INNER?\nI asked the magic box and it spat out paragraph after paragraph of stuff about cardinality and indexing, of which go way over my head and I don't have access to check. But basically:\n\nI work in a system where (as a for instance) there are plenty of obvious 1:1 joins, such as:\n\n    SELECT\n      ol.ProductId,\n      p.Name\n    FROM OrderLines ol\n    JOIN Products p\n    ON ol.ProductId = p.Id\n    WHERE ol.OrderId = '1234'\n\nSo this should give you the product ids on the order, and then their text name from the Products table.\n\nI'm finding in multiple tables and instances that are pk or other 1:1 joins like this, that an inner join can take ~30 seconds to run, where a left outer runs instantly.\n\nThe data output is the same, but the timing is all over, and I'm wondering on what the main/obvious reasons for this are?", "subreddit": "r/SQL", "upvotes": 20, "date": "[PHONE]", "source": "https://www.reddit.com/r/SQL/comments/1tylrxf/what_are_some_obvious_reasons_a_11_join_would/"}
{"prompt": "SSIS is worth it and in demand in today IT market?", "completion": "SSIS is worth it and in demand in today IT market?\nI am learning SQL and SSIS for ETL process. My question is with ADF (Azure Data Factory) cloud based solution becoming more prominent. Is learning SSIS still worth it?", "subreddit": "r/SQL", "upvotes": 20, "date": "[PHONE]", "source": "https://www.reddit.com/r/SQL/comments/1st8yyg/ssis_is_worth_it_and_in_demand_in_today_it_market/"}
{"prompt": "What jobs do you have now? Are you happy", "completion": "What jobs do you have now? Are you happy\nI’m a college student in my final year. I don’t really have many people to talk to about this since a lot of people I know are either in their first year or have already graduated and rushed out to find work.(so think I don't know crowd vs I need work! Crowd)\n\nIt’s wild how many people don’t really talk about their future in college or realize how important internships are. So far, I’ve had two internships. The one I have now is through the WordPress Foundation, and I’m going the testing/QA route to try to gain experience that can eventually help me get into data analysis.\n\nQuestion for you guys:\n\n1. What do you do?\n\n2. How did you start out? Did you jump straight into your current field, or did you start somewhere like help desk?\n\n3. What advice would you give someone starting out with little experience?\n\n4. Are you happy with your career, or do you regret choosing this field?\n\n5. How hard was it for you to find work when you first started, and how hard would it be for you to find another job if you left your current job?\n\nAnd finally\n\nwhat was your first job in the field that got you in the door and how was it", "subreddit": "r/SQL", "upvotes": 20, "date": "[PHONE]", "source": "https://www.reddit.com/r/SQL/comments/1vstqgc/what_jobs_do_you_have_now_are_you_happy/"}
{"prompt": "Meet Migrata: a CLI that treats SQL as state and lets you diff your schema and apply changes without migration files", "completion": "Meet Migrata: a CLI that treats SQL as state and lets you diff your schema and apply changes without migration files\n*TLDR; Migrata is a CLI that lets you inspect, diff, and apply changes using plain SQL. It's like Terraform, but for your database.*\n\nI built this tool because of the pain I experienced working with migration files at my job. These databases are shared across many teams and even more applications.\n\nLike many organizations, we follow a file-based migration approach: a folder for each change set, files with targeted changes per component, all tracked in Git. There are strict processes for approvals and promotions. The problem is that this approach results in thousands of migration files piling up over time. To mitigate this, we have a change approval board whose sole job is to coordinate with database admins to apply these scripts.\n\nMost of their time is spent understanding what's changing and if there are any conflicts. It's not uncommon for two separate scripts from different change sets to modify the same things. Centralizing these changes would drastically lower the time needed to review and approve them.\n\nAfter working with Terraform for years, I knew there were better ways to track state and apply changes. But unlike the cloud, databases already have a schema language to describe their state: plain SQL. Instead of inventing a new DSL, my tool treats your SQL schema as the source of truth and diffs against it directly.\n\nIn practice, this gives you the best of both worlds: readable SQL and a declarative schema, with each component defined once. Changes are centralized, not scattered across layers of migration files.\n\nI've been working on this particular project for the past 17 months on evenings and weekends, and finally feel like it's at a state where it's good enough to share\n\n**Core Feature:**\n\n* Comparing two schema sources and generating a clear diff\n* See exactly *what* will change before anything is applied\n* Manually approve and apply changes\n\n**How it works:**\n\n1. Run the \"inspect\" command to inspect your live database schema and sync it to your local file system.\n   1. This does deliberate scans on your target schemas; no psql dumps needed.\n2. Make a single or multiple changes in your local editor\n3. Run the \"diff\" command to detect differences and generate a plan in the console.\n   1. Internally, we build up a dependency graph so we know how and when to apply a change and who's affected.\n4. Manually approve and apply changes\n\n**Features:**\n\n* Better Diffs\n   * This tool shows the user modifications and query plans side-by-side. You always know where a change is coming from and why. Traceability is paramount\n* Impact Analysis:\n   * The diff includes a list of downstream components affected by a change\n* Risk Classification:\n   * Every planned migration is labeled Safe, Warning, or Destructive so you can assess impact at a glance. Warnings and destructive changes are summarized separately with counts.\n* Full column lifecycle management:\n   * Changes to columns are analyzed, and safe multi-step patterns are used to transform columns. Indexes & constraints are always preserved after changes\n* Custom Organization:\n   * You can organize your schema locally however you like (single file or deeply nested directories). It loads everything and automatically builds a dependency graph no matter how you organize your schemas\n* Local Validation:\n   * The tool will spin up an ephemeral database in docker where it can execut", "subreddit": "r/SQL", "upvotes": 20, "date": "[PHONE]", "source": "https://www.reddit.com/r/SQL/comments/1vf91fn/meet_migrata_a_cli_that_treats_sql_as_state_and/"}
{"prompt": "LibreDB Studio: Self-hosted browser SQL IDE, next to Postgres instead of on every laptop", "completion": "LibreDB Studio: Self-hosted browser SQL IDE, next to Postgres instead of on every laptop\n\nAffiliation: I’m the maintainer of LibreDB Studio.\n\nFor years the SQL workflow for a team looked like this, on every engine I touched (PostgreSQL, MySQL, Oracle, SQL Server, SQLite, MariaDB, Clickhouse ...):\n\n\\- install a desktop client on each laptop\n\n\\- VPN / SSH tunnel so the client can even see the box\n\n\\- hunt schema in one pane, write the query in another\n\n\\- run something that hangs and hope cancel actually kills it\n\n\\- EXPLAIN in a second window\n\n\\- onboard the next person by repeating the install\n\nor try on their own web editor(pgAdmin, phpMyAdmin ...)\n\nI got tired of the editor living on the laptop instead of next to the database, so I built a self-hosted browser SQL IDE. Deploy once (Docker / Helm / \\``npx \"@libredb/studio\"`\\`,  one-click with rancher, dokploy, digitalocean), open a URL, same UI for the engines above.\n\nNot trying to replace DBeaver or DataGrip, different access model. Postgres is the reference implementation: pooled connections, explicit BEGIN/COMMIT/ROLLBACK with an auto-rollback timeout, cancel through pg\\_cancel\\_backend on the tracked PID. Schema tree stays usable on large catalogs (tables first, relationships second). Optional db-agent to SQL is schema-constrained and read-only runs go through BEGIN READ ONLY, not “trust the prompt.”\n\nMIT. One command:\n\n`docker run -p 3000:3000 libredb/libredb-studio`\n\nIf you try it, I actually want the unkind notes:\n\n\\- does cancel / transaction rollback behave the way you’d expect on Postgres?\n\n\\- what’s missing vs the desktop client you already live in?\n\n\\- is a browser editor a non-starter for you, and why?\n\nSource: [https://github.com/libredb/libredb-studio](https://github.com/libredb/libredb-studio)", "subreddit": "r/SQL", "upvotes": 19, "date": "[PHONE]", "source": "https://www.reddit.com/r/SQL/comments/1vy985w/libredb_studio_selfhosted_browser_sql_ide_next_to/"}
{"prompt": "help on sql interview", "completion": "help on sql interview\nHello!\n\nI am not very proud of it but I kinda overstated my SQL experience on my resume and now I’ve moved forward in the interview process. I have an interview with a manager next week, and HR told me that he will include some SQL-related questions.\n\nI did study SQL a bit in college, mainly in a business intelligence context, but that's it.. It's not a developper role so I don't think the questions will be advanced, it’s more of a business-facing technico-functional position.\n\nDo you guys have any idea what kind of SQL questions they might ask? I’ve already watched some YouTube videos covering the basics like SELECT, JOIN, WHERE, etc., but I’m not sure if that will be enough.\n\n\nThanks a lot", "subreddit": "r/SQL", "upvotes": 19, "date": "[PHONE]", "source": "https://www.reddit.com/r/SQL/comments/1udjtes/help_on_sql_interview/"}
{"prompt": "I am building SQL notebooks into an open source database client", "completion": "I am building SQL notebooks into an open source database client\nHi guys!\n\nI've been working on Tabularis (open source cross-platform db client) and I'm working on a notebooks feature that i think people here might find interesting.\n\nThe core idea: SQL cells + markdown cells in a single document, running against your live database connection. no separate kernel, no python, just SQL.\n\nThe feature I keep coming back to is cell variable references, you write `{{cell_3}}` in your SQL and it takes the result set from cell 3 and injects it as a CTE. means you can chain analyses without building giant nested queries. for ad-hoc exploration this is a huge workflow improvement.\n\nYou also get:\n\n* **inline charts:** bar, line, pie. select label column + value columns, switch between types. nothing fancy but enough for quick visual checks\n* **notebook parameters:** define params once, use in all cells. good for parameterized reports\n* **run all with stop on error:** shows a summary of what succeeded/failed/skipped with links to the failing cells\n* **parallel execution:** mark independent cells with a lightning bolt, they run concurrently during run all\n* **execution history:** every cell tracks its last 10 runs, you can restore any previous query + result\n* **csv/json export** per cell, or export the whole notebook as self-contained HTML\n* **drag & drop** reordering, collapsible sections, resizable result panels\n\nIt supports all of databases supported by Tabularis.\n\nThe notebook file format is json-based (`.tabularis-notebook`).\n\nThere's a demo database + sample notebook in the repo under `/demo`.\n\nGithub: [https://github.com/debba/tabularis](https://github.com/debba/tabularis)\nWIP Branch: [https://github.com/debba/tabularis/tree/feat/notebooks](https://github.com/debba/tabularis/tree/feat/notebooks)\n\nFeedback welcome, especially around the cell reference syntax and what else would make this useful for your workflow.", "subreddit": "r/SQL", "upvotes": 19, "date": "[PHONE]", "source": "https://www.reddit.com/r/SQL/comments/1saktzq/i_am_building_sql_notebooks_into_an_open_source/"}
{"prompt": "I struggle with SQL interviews", "completion": "I struggle with SQL interviews\nI’ve been working with SQL for years and recently discovered that my issue in interviews is the terminology. For example, if an interviewer shows me an excel spreadsheet with two tables and asks me how to pull x information from it, I get nervous and end up articulating the answer very poorly, leaving out key words such as “joins”. Another example is if they asked to show it using a CTE, and this term would confuse me during the interview, but after the interview I’ll realize that I’ve written many queries that use CTEs. My question is how do I fix this? How do I prepare for such questions better? Are there any sources or tips or general advice that anyone has? I’ve not found any site that gives practice on the excel-style of questions", "subreddit": "r/SQL", "upvotes": 19, "date": "[PHONE]", "source": "https://www.reddit.com/r/SQL/comments/1v4orzs/i_struggle_with_sql_interviews/"}
{"prompt": "Anyone Want to Learn SQL for Free?", "completion": "Anyone Want to Learn SQL for Free?\nI was thinking about this today...\n\nBack in college, I used to teach quite a bit. Later, as I progressed in my IT career, I ended up mentoring a few people in my company who were just getting started. Watching someone go from \"I have no idea what's happening\" to confidently writing queries on their own was always incredibly rewarding.\n\nIt's been years since I've done that, and I genuinely miss it.\n\nSo, I'm thinking of starting a few **free live SQL sessions** for complete beginners or anyone who wants to strengthen their fundamentals.\n\nThe goal isn't to memorize syntax—it's to understand how to think in SQL. We'll cover the basics from scratch, work through practical examples, solve real SQL problems together, and do interview-style questions with plenty of Q&A.\n\nI'm **not looking to make money** from this. If, after a few sessions, you think it was genuinely helpful, buying me a coffee would be more than enough. 😄\n\nIf this sounds interesting, send me a DM or leave a comment. If enough people are interested, I'll organize a small group and we'll get started.\n\nJust looking to give back to the community\n\n**Note:** This is **not** an advanced SQL course.\n\nIt's meant for people who have **little to no SQL experience**—whether you're a student, switching careers, or someone whose job occasionally requires SQL but you've never really learned it.\n\nWe'll start from **absolute scratch**: what databases are, how SQL works, and gradually build up to writing queries confidently. By the end, my goal is that you'll be comfortable handling the kind of basic to intermediate SQL tasks that come up in many office and analyst roles.\n\nIf you're already comfortable with SQL, writing complex queries, optimizing performance, or preparing for senior-level interviews, this probably isn't the right fit..", "subreddit": "r/SQL", "upvotes": 19, "date": "[PHONE]", "source": "https://www.reddit.com/r/SQL/comments/1v1y24f/anyone_want_to_learn_sql_for_free/"}
{"prompt": "Free ebook: Mastering PostgreSQL (Supabase + Manning)", "completion": "Free ebook: Mastering PostgreSQL (Supabase + Manning)\nHi r/SQL,\n\nStjepan from Manning here. I'm posting on behalf of Manning with mods' approval.\n\nWe’re sharing a **free resource** with the community that might be useful if you spend a lot of time in PostgreSQL. It’s a complimentary ebook created by **Supabase and Manning Publications**:\n\n[Mastering PostgreSQL: Accelerate Your Weekend Projects and Seamlessly Scale to Millions](https://hubs.la/Q0469KbQ0)\n\n[Mastering PostgreSQL](\n\nThe idea behind it is simple: most developers learn enough SQL to get things working, but Postgres has a lot of depth that people only discover years later. This guide tries to shorten that path a bit.\n\nThe material focuses on practical things that tend to matter once your database stops being a small side project. Topics include:\n\n* writing modern SQL that takes advantage of PostgreSQL features\n* using built-in capabilities like full-text search\n* choosing appropriate data types for correctness and performance\n* avoiding common table and index design mistakes\n* structuring schemas so projects can grow without constant rewrites\n\nIt’s written with application developers in mind. The examples start small (weekend-project scale) and gradually touch on patterns that hold up when the data and traffic grow.\n\nIf you already work with Postgres daily, some of it will likely feel familiar. But we’ve heard from readers that the sections on schema design, indexing decisions, and lesser-used Postgres features tend to surface ideas people hadn’t tried yet.\n\nThe ebook is **completely free**. If you download it and end up reading through it, I’d be curious to hear what parts you found useful or what you’d add based on your own experience with PostgreSQL.\n\nIt feels great to be here. Thanks for having us.\n\nCheers,\n\nStjepan", "subreddit": "r/SQL", "upvotes": 18, "date": "[PHONE]", "source": "https://www.reddit.com/r/SQL/comments/1rpx7br/free_ebook_mastering_postgresql_supabase_manning/"}
{"prompt": "How do you parse an xml that's in a string format?", "completion": "How do you parse an xml that's in a string format?\nI have xml data that's for God knows why it's in string format. And the fking thing is so messed up or at least I think it's messed up because it's not consistent. Sometimes there is something else in there. Xml is something like this:\n\n<Test>\n\n<Test1 />\n\n<Test2 Name=\"abcdname\" Age=\"123\" Gender=\"Xyz\" />\n\n....\n\n...\n\n...\n\n</Test>\n\nRegex is not an option.\n\nSubstring is not an option.\n\nBecause it's so messed up it's not consistent.\n\nI just need to somehow parse and get that Name, Age, Gender values using Sql/Databricks sql\n\nPlease, help you mate.", "subreddit": "r/SQL", "upvotes": 18, "date": "[PHONE]", "source": "https://www.reddit.com/r/SQL/comments/1we32qt/how_do_you_parse_an_xml_thats_in_a_string_format/"}
{"prompt": "What I should learn after SQL PL/SQL ??", "completion": "What I should learn after SQL PL/SQL ??\nso i am 24 years old and unemployed from past 4/5 months, i have experience in banking and manufacturing now after sending hundreds of application still cant get a interview i learned ssis and power bi for the data analyst which is go nowhere for me now i am getting my hands on snowflake and after that aws basic so now i want just to ask if you were in my position what suggestion you give or what will be your next steps...", "subreddit": "r/SQL", "upvotes": 18, "date": "[PHONE]", "source": "https://www.reddit.com/r/SQL/comments/1ttm8y6/what_i_should_learn_after_sql_plsql/"}
{"prompt": "Fresh Data Analyst (SQL) | Applied on LinkedIn, Naukri & Indeed but getting almost no responses. What else should I try?", "completion": "Fresh Data Analyst (SQL) | Applied on LinkedIn, Naukri & Indeed but getting almost no responses. What else should I try?\nHi everyone,\n\nI'm a 2026 fresher looking for an entry-level Data Analyst / SQL role.\n\nSo far I've applied through LinkedIn, Naukri, and Indeed, but I'm barely finding relevant fresher openings or getting responses.\n\nMy current skills are:\n\n• SQL\n\n• Python\n\n• ETL\n\n• A couple of Python + SQL projects\n\nHas anyone here landed a Data Analyst role recently? Which job portals, company career pages, or strategies actually worked for you?\n\nI'd really appreciate any suggestions. Thanks!", "subreddit": "r/SQL", "upvotes": 18, "date": "[PHONE]", "source": "https://www.reddit.com/r/SQL/comments/1ukm0xd/fresh_data_analyst_sql_applied_on_linkedin_naukri/"}
{"prompt": "SQL Beginners/Intermediate Study Group – Bangalore", "completion": "SQL Beginners/Intermediate Study Group – Bangalore\nHi everyone,\n\nI have experience in SQL. Recently started preparing for SQL interviews . I’m currently reading SQL: The Complete Reference to build strong fundamentals first. After that, I plan to practice consistently on LeetCode and HackerRank to really strengthen my problem-solving skills.\n\nMy goal is to understand SQL deeply — not just solve questions, but think in terms of query execution, optimization, and solid foundations.\nIf anyone is also preparing SQL and would like to study together (discussions, practice sessions, doubt-solving), I’d love to connect.\n\nI’d especially prefer someone staying around Marathahalli area, Bangalore, so we could even plan occasional in-person study sessions.\n\nLet me know if you’re interested!", "subreddit": "r/SQL", "upvotes": 18, "date": "[PHONE]", "source": "https://www.reddit.com/r/SQL/comments/1rhobdd/sql_beginnersintermediate_study_group_bangalore/"}
{"prompt": "How do I level up to writing complex SQL stored procedures in real industrial systems?", "completion": "How do I level up to writing complex SQL stored procedures in real industrial systems?\nHey everyone,\n\nI work with industrial systems (MES/SCADA) and I've been diving deep into complex stored procedures lately — we're talking about reports that pull data from multiple AMPLA servers, cross dozens of tables with chains of LEFT JOINs using different aliases for the same table (day/month/year windows), UNION blocks for each KPI, dynamic date calculations, fallback logic between reconciled data and raw sensor data, and so on.\n\nI can read and understand the code, but I want to level up to the point where I can write and optimize this kind of procedure from scratch.\n\nWhat I'm specifically struggling with:\n\n* Designing the JOIN structure when you need the same table filtered by multiple time windows simultaneously\n* Knowing when to use subqueries vs more aliases vs temp tables\n* Optimizing performance when the procedure has 100+ INSERT/SELECT blocks\n* Best practices for error handling (TRY/CATCH around external server calls that might be down)\n\nAny books, courses, YouTube channels or just general advice would be hugely appreciated. Preferably things that go beyond the basic SELECT/WHERE stuff and actually cover real-world complexity.\n\nThanks in advance 🙏", "subreddit": "r/SQL", "upvotes": 18, "date": "[PHONE]", "source": "https://www.reddit.com/r/SQL/comments/1uctuht/how_do_i_level_up_to_writing_complex_sql_stored/"}
{"prompt": "Is there a way to findout if any particular sector/industry has shortage of SQL analysts ?", "completion": "Is there a way to findout if any particular sector/industry has shortage of SQL analysts ?\nJust contemplating if there is some way of finding this ?\n\nNot as accurate but if its possible !", "subreddit": "r/SQL", "upvotes": 18, "date": "[PHONE]", "source": "https://www.reddit.com/r/SQL/comments/1vwldkv/is_there_a_way_to_findout_if_any_particular/"}
{"prompt": "SQL analysis → Power BI visualization | how does this actually work in real life?", "completion": "SQL analysis → Power BI visualization | how does this actually work in real life?\nI've been analyzing data in SQL and now I want to visualize it in Power BI, but I'm confused about the workflow between the two tools.\n\nI already know how to connect Power BI to data sources: databases, CSVs, folders. that's not the problem. What I'm struggling to understand is the purpose of analyzing in SQL if Power BI can't directly \"receive\" that analysis in a clean way.\n\nI know two options exist: exporting query results from MySQL, or pasting a query directly when setting up a connection in Power BI. But are there other ways to do this? And is it even necessary to pre-analyze in SQL, or should the analysis just happen inside Power BI using DAX/Power Query?\n\nHow does this actually get done in a real-world setting? I can't find any videos that specifically address this handoff between SQL analysis and Power BI visualization , most tutorials treat them as completely separate topics.\n\nIf anyone can share resources, a workflow breakdown, or just explain how your team handles this, I'd really appreciate it. I feel like I'm missing a fundamental concept here.", "subreddit": "r/SQL", "upvotes": 18, "date": "[PHONE]", "source": "https://www.reddit.com/r/SQL/comments/1r389ex/sql_analysis_power_bi_visualization_how_does_this/"}
{"prompt": "What is the hardest SQL bug to detect when the query never throws an error?", "completion": "What is the hardest SQL bug to detect when the query never throws an error?\nSome SQL bugs don't cause any error. The query runs successfully and the result even looks correct.\n\nFor example, an incorrect JOIN, unexpected duplicates, NULL handling, or a wrong date filter can silently produce incorrect results.\n\nWhat is the most difficult SQL bug you've encountered where the query ran successfully but the data was wrong?", "subreddit": "r/SQL", "upvotes": 18, "date": "[PHONE]", "source": "https://www.reddit.com/r/SQL/comments/1wseaii/what_is_the_hardest_sql_bug_to_detect_when_the/"}
{"prompt": "Getting workday hr data into a queryable format for workforce analytics is turning into a nightmare", "completion": "Getting workday hr data into a queryable format for workforce analytics is turning into a nightmare\n&#x200B;\n\nOur company uses workday for all hr functions and the people analytics team wants to run workforce analytics in the warehouse alongside financial data from netsuite and project data from our internal systems. The challenge is that workday's data model is incredibly complex with deeply nested worker objects that contain position history, compensation history, benefit elections, time off balances, and custom objects all bundled together.\n\nWhen this data lands in the warehouse it comes as these massive json structures per worker that are painful to query in sql. Something as simple as \"show me headcount by department with average tenure\" requires parsing through nested arrays of position assignments, figuring out which assignment is current, calculating tenure from the hire date, and handling all the edge cases like transfers between departments and leaves of absence. The sql is a mess of lateral joins and json parsing functions.\n\nOur analytics team knows sql well but they shouldn't need to write 50 line queries with multiple cte layers just to get basic headcount numbers. Is there a better approach to structuring workday data in a warehouse for sql accessibility? Are people flattening this at ingestion or at the transform layer?", "subreddit": "r/SQL", "upvotes": 17, "date": "[PHONE]", "source": "https://www.reddit.com/r/SQL/comments/1s2d62s/getting_workday_hr_data_into_a_queryable_format/"}
{"prompt": "Interview with a DBA [7:38]", "completion": "Interview with a DBA [7:38]\nI set query cache size to 1G. We ones believes in miracles...\n\nVideo of a seemingly 2008 type DBA. What're your thoughts on DBA roles today?\nHow is it changing with serverless?", "subreddit": "r/SQL", "upvotes": 17, "date": "[PHONE]", "source": "https://www.reddit.com/r/SQL/comments/1ukfrhc/interview_with_a_dba_738/"}
{"prompt": "How do you decide which incremental strategy to use in your SQL models", "completion": "How do you decide which incremental strategy to use in your SQL models\nChoosing the right incremental strategy matters: in bigquery it reduces the amount of data scanned, while in clickhouse it means less CPU, I/O, and background merging.\n\nbut tbh, data/analytics engineers sometimes optimize this too early, if a table is small or rarely changes, a view or \\`create+replace\\` is easier than a convoluted incremental model. Sometimes full refreshes are just good enough\n\nBefore choosing anything, I normally ask: do old rows change? is \\`updated\\_at\\` reliable? can rows disappear? is the data truly append only? do you have proper primary keys & partitions? and how late can updates arrive?\n\nhere's an overview:\n\n\\* \\`append\\` -> the source is genuinely append only\n\n\\* \\`merge\\` -> existing rows change and there's a stable primary key\n\n\\* \\`delete+insert\\` or \\`time\\_interval\\` -> you can safely rebuild a complete group or time window\n\n\\* SCD2 -> you need the full history, not just the latest version\n\nwith \\`merge\\`, NULL keys can be inserted again on every run because \\`NULL = NULL\\` isn't true, I have personally lost sleep over this... (in bigquery)\n\nwith \\`delete+insert\\` or \\`time\\_interval\\`, only delete what you can fully rebuild - incomplete partitions, bad boundaries, or late arrivals can create gaps or duplicates.\n\nThat's why I always add quality checks that catch issues the strategy can cause: \\`not\\_null\\` & \\`unique\\` for merge keys, duplicate checks for rebuilt windows, and row-count or freshness checks where they make sense.\n\nIn SQL pipelines the most frustrating (and silent killer) is that a pipeline status can be successful, but that only means the SQL ran, but doesn't guarantee that the result is correct. That's why quality checks are there to catch the other issues.\n\nand if timestamps and lookback windows still can't capture changes reliably, CDC is an option... just with more state, replay logic, and operational headaches.\n\nthe image below is an example of a \\`time\\_interval\\` strategy and its rendered clickhouse query (don't mind the wrapped date overlappign with INSERT)\n\n\nI'm curious what other criteria do people have in mind when they try to evaluate which strategy to go with? I think this is more relevant to analytics engineers, not so much the operational/transactional side.", "subreddit": "r/SQL", "upvotes": 17, "date": "[PHONE]", "source": "https://www.reddit.com/r/SQL/comments/1vqlbqk/how_do_you_decide_which_incremental_strategy_to/"}
{"prompt": "Any recommendations for YouTube specifically content creators on SQL.", "completion": "Any recommendations for YouTube specifically content creators on SQL.\n​This might be odd, but I love listening to guys on YouTube talking about SQL...although I rarely have to use it. Any recommendations outwith Alex the analyst?\n\nThanks in Advance.", "subreddit": "r/SQL", "upvotes": 17, "date": "[PHONE]", "source": "https://www.reddit.com/r/SQL/comments/1rwf4qr/any_recommendations_for_youtube_specifically/"}
{"prompt": "What execution plan mistake do juniors make most often when they analyze queries?", "completion": "What execution plan mistake do juniors make most often when they analyze queries?\nA thing I see pretty often: junior devs open an execution plan, notice one big expensive-looking step, and lock onto that right away.\n\nBut the real issue is often somewhere else. Bad row estimates, missing index, messy join logic, parameter sniffing, key lookups, or just reading the plan without enough context.\n\nWhat mistake do you see most often?\n\nCould be stuff like chasing cost percentages, treating every scan like a disaster, or not comparing estimated vs actual rows. Also curious what helped you personally get better at reading plans, because most people learn this part the hard way.", "subreddit": "r/SQL", "upvotes": 17, "date": "[PHONE]", "source": "https://www.reddit.com/r/SQL/comments/1swwva2/what_execution_plan_mistake_do_juniors_make_most/"}
{"prompt": "Looking for a free (or cheap) database for storing 5-10 million rows", "completion": "Looking for a free (or cheap) database for storing 5-10 million rows\nHey guys, I am a college student trying to make a site. It's politics, so I don't wanna go in too deep, but essentially it is a map that lets you click on a state and select a senator, or a representative district and you can see how much money they took in the recent intake.\n\nThe main issue I have is importing the data. I plan to import the raw data into one database (contributions\\_raw) and then classify it further on. However importing the raw data is easier said then done. I have to import 2 files, one is 120,000 KB the other is 10.7 GB. I know, thats probably nothing for you guys but the most I ever worked with before was \\~10,5000 rows lol\n\nI know how to read the txt files they give and get the information I need, it's just the volume is way too much. I currently am using Cloudflare D1 (my whole site stack is on CF) and even with the Paid plan thanks to being a stupid I have no idea how to do this. The Worker times out importing the 120,000 KB file so I can imagine the 10.7 GB crashing\n\nI came here wondering if anyone has done something like this with Cloudflare, and if so how. Otherwise should I jump ship to another stack, although I like Cloudflare's system.\n\n\nLink to the database schemas: [https://github.com/chexedy/moneyindc/blob/main/src/data/database.txt](https://github.com/chexedy/moneyindc/blob/main/src/data/database.txt)\nThe FEC data (the two things I am trying to import are \"Contributions by individuals\" and  \"Contributions by committees to candidates & independent expeditures\"\n\nSorry if this is a silly question I know 10 GB is probably nothing for people who do this for a living but I'm tryna enter the big leagues I guess so if you have a solution I would appreciate it!", "subreddit": "r/SQL", "upvotes": 16, "date": "[PHONE]", "source": "https://www.reddit.com/r/SQL/comments/1qcgcut/looking_for_a_free_or_cheap_database_for_storing/"}
{"prompt": "Built a free and open source tool to make schema evolution visual and SQL migrations simpler.", "completion": "Built a free and open source tool to make schema evolution visual and SQL migrations simpler.\nHey Engineers!\n\nMost of us have faced this: while working on a project, you need to make changes to your database schema **(add tables, alter or drop columns, create indexes, update relationships, etc.)**. This is where database migrations come in, you either handle them manually with SQL or rely on an ORM.\n\nAfter a while, this process becomes repetitive and time-consuming.\n\nThat's why I built a tool called **StackRender**. It helps generate well-written database migrations directly from ER Diagram (ERD) changes.\n\nThe workflow is pretty simple:\n\n* Design a database from scratch or import an existing one.\n* Visualize and explore the schema through an ER Diagram.\n* Perform the changes you want visually ( no coding required ) .\n* StackRender detects the changes and generates production-ready database migration **scripts (UP/DOWN)**, similar to how ORMs handle migrations.\n\nThis approach helps close the gap between design and implementation, making database migrations easier to manage while reducing the risk of errors.\n\nThe tool is free and open source, and currently supports **PostgreSQL, MySQL, MariaDB, SQLite, Oracle, and Microsoft SQL Server.**\n\nTry it out here: [www.stackrender.io](http://www.stackrender.io/)\n\nGithub repo : [https://github.com/stackrender/stackrender](https://github.com/stackrender/stackrender)\n\nThanks a lot!", "subreddit": "r/SQL", "upvotes": 16, "date": "[PHONE]", "source": "https://www.reddit.com/r/SQL/comments/1uaxjfj/built_a_free_and_open_source_tool_to_make_schema/"}
{"prompt": "Implementation routine", "completion": "Implementation routine\nHi all,\nI've created one complex ETL using few SP's, main reason for this dev was to replace existing legacy process that was running too long ( 7hrs+) and was barely manageable.\nDuring our go/no go meeting business (end) user  asked me if I'm sure it will work how it claimed, how I managed to run new ETL in 1 hr if old was 6-7hrs.  I said 'yes, of course, and it was verified by my peers. I used a lot optimization both in code and biz logic'.\n\nThen user said: \"OK, but I want to run this ETL for 10 days without any glitches and after that I will make my decision.\" Which sound like he didn't give dev team 100% trust.\n\nI'm pretty new in soft development, is it normal ? what do you think about this approach ? Appreciate you feedback. My thought was that end user doesn't need to into all details of dev, for them it will be total transparent switch.\n\nBest>", "subreddit": "r/SQL", "upvotes": 16, "date": "[PHONE]", "source": "https://www.reddit.com/r/SQL/comments/1vk4ndz/implementation_routine/"}
{"prompt": "What is a good SQL Client with good modern UI or one that has good UX", "completion": "What is a good SQL Client with good modern UI or one that has good UX\nI am currently using phpMyAdmin provided by plesk and I just find it very annoying to use and I would like to know if you guys know a good Client that has modern and clean ui that also has good ux", "subreddit": "r/SQL", "upvotes": 16, "date": "[PHONE]", "source": "https://www.reddit.com/r/SQL/comments/1wh6ch7/what_is_a_good_sql_client_with_good_modern_ui_or/"}
{"prompt": "How does a Recursive CTE work exactly?", "completion": "How does a Recursive CTE work exactly?\n    With RecursiveEven20 As\n    (\n    Select 0 as Numbers,\n    0 as RunningCount\n\n    Union All\n\n    Select Numbers + 2,\n    Count(RunningCount) Over() As RunningCount\n    From RecursiveEven20\n    Where RunningCount < 19\n    )\n    Select *\n    From RecursiveEven20;\n\n\nFrom how much I know about recursive CTE, I thought this would work, Initially I felt I was doing a semantic error, then when I tried to see where the fault is, I realised Count isn't incrementing at all, its as if only the last feedback row is available to it. I tried using explicit frame window, same result. I think I dont understand exactly how recursie CTE works, I tried AI, its explanation is bit difficult to understand.", "subreddit": "r/SQL", "upvotes": 16, "date": "[PHONE]", "source": "https://www.reddit.com/r/SQL/comments/1w7adcq/how_does_a_recursive_cte_work_exactly/"}
{"prompt": "Roles that focus on SQL and how to get them!", "completion": "Roles that focus on SQL and how to get them!\nSo I have given like 5 in person interview and max 10 online assessments for various roles (applied count is in 100s) and the only thing I understood is I am able to frame queries faster (accurately) than the coding (aka java ) so I was wondering if there are roles that are SQL heavy open for new grads ( i will be a new grad in may) or am i applying in void!\n\ncourse work I took online that is sql specific :\nDatabase Structures and Management with MySQL (coursera)\nIntroduction to Databases(Coursera)\n\nA mini project that I built is this one that uses sqlite and fastapi and gives some customer segmentation analysis report\n\n(I have other projects which focus on rag, ml,web but I find SQL quires more understandable)\n\nI want to build my resume so that at least after 3 months I will be able to get interviews that are SQL specific? or are these roles more inclined to take experienced people?\n\n(note: I am not saying I am an expert because I still am learning CTEs which I find a little bit difficult but I am able to atleast pin point how to approach SQL questions during interviews compared to others)", "subreddit": "r/SQL", "upvotes": 16, "date": "[PHONE]", "source": "https://www.reddit.com/r/SQL/comments/1qnlety/roles_that_focus_on_sql_and_how_to_get_them/"}
{"prompt": "The best SQL for data analytics for Europe/Middle East. MySQL vs PostgreSQL vs (Any other option)", "completion": "The best SQL for data analytics for Europe/Middle East. MySQL vs PostgreSQL vs (Any other option)\nHello everyone. as the title says I want to be a data analyst. But before going to college I would like to know the programs. Apparently some of the most used are MySQL and PostgreSQL (which apparently is growing) as someone who is beginning (with help of Fiero Code). What SQL should I download? Something easy that I could learn and maybe keep it as “mine”", "subreddit": "r/SQL", "upvotes": 16, "date": "[PHONE]", "source": "https://www.reddit.com/r/SQL/comments/1r6ryb7/the_best_sql_for_data_analytics_for_europemiddle/"}
{"prompt": "Starting my ETL developer job in a bank any advice, tips, life hacks anything.", "completion": "Starting my ETL developer job in a bank any advice, tips, life hacks anything.\nAfter job hunting for half a year, I was finally able to land a job (Thank God!). This is my first job that is aligned with my degree. The ETL tool I’m going to use is SSIS. I know the basics of it. And I think I gonna use Microsoft SQL server for the RDMS. I practice Several times the sql question on Leet code.", "subreddit": "r/SQL", "upvotes": 16, "date": "[PHONE]", "source": "https://www.reddit.com/r/SQL/comments/1vuhoim/starting_my_etl_developer_job_in_a_bank_any/"}
{"prompt": "When should you stop optimizing a SQL query?", "completion": "When should you stop optimizing a SQL query?\nIt's easy to keep optimizing a SQL query once you start looking at execution plans, indexes, joins, and scans. But at some point, the improvement may not be worth the extra effort.\n\nFor example, if a query takes 10 seconds and you reduce it to 2 seconds, that's a big improvement. But would you spend another few hours trying to reduce it from 2 seconds to 1.5 seconds?\n\nHow do you decide when a query is “fast enough”?\n\nDo you consider:\n\n* Query execution time\n* Number of users running it\n* Frequency of execution\n* CPU/memory usage\n* Data volume and future growth\n* Business requirements or SLA\n\nWhere do you personally draw the line between useful optimization and over-optimization?", "subreddit": "r/SQL", "upvotes": 16, "date": "[PHONE]", "source": "https://www.reddit.com/r/SQL/comments/1wndshk/when_should_you_stop_optimizing_a_sql_query/"}
{"prompt": "rainfrog (0.4.1) now has autocomplete!", "completion": "rainfrog (0.4.1) now has autocomplete!\nrainfrog ([https://github.com/achristmascarl/rainfrog](https://github.com/achristmascarl/rainfrog)) is a database terminal tool; the goal is to provide a lightweight, keyboard-first TUI for interacting with databases. It currently supports Postgres, MySQL, SQLite, Oracle, and DuckDB.\n\nv0.4.1 introduces a long-awaited (by me, not sure if anyone else was waiting for it...) autocomplete implementation, along with autopairs for quotes/parentheses/brackets. The full list of features and configuration options is in the README!", "subreddit": "r/SQL", "upvotes": 16, "date": "[PHONE]", "source": "https://www.reddit.com/r/SQL/comments/1v5y9kq/rainfrog_041_now_has_autocomplete/"}
{"prompt": "First time creating an ER diagram with spatial entities on my own, do these SQL relationship types make sense according to the statement?", "completion": "First time creating an ER diagram with spatial entities on my own, do these SQL relationship types make sense according to the statement?\nHi everyone,\nI’m a student and still pretty new to SQL Relationships… This is my first time creating a diagram that is spatial like this on my own for a class, and I’m not fully confident that it makes sense yet.\n\nI’d really appreciate any feedback (whether something looks wrong, what could be improved, and also what seems to be working well). I’ll drop the context I made as well for the map below:\n\nThe city council of the municipality of San Juan needs to store information about the public lighting system installed in its different districts in order to ensure adequate lighting and improvements. The system involves operator companies that are responsible for installing and maintaining the streetlights.\n\nFor each company, the following information must be known: its NIF (Tax Identification Number), name, and number of active contracts with the districts. It is possible that there are companies that have not yet installed any streetlights.\n\nFor the streetlights, the following information must be known: their streetlight ID (unique identifier), postal code, wattage consumption, installation date, and geometry. Each streetlight can only have been installed by one company, but a company may have installed multiple streetlights.\n\nFor each street, the following must be known: its name (which is unique), longitude, and geometry. A street may have many streetlights or may have none installed.\n\nFor the districts, the following must be known: district ID, name (unique), and geometry. A district contains several neighborhoods. A district must have at least one neighborhood.\n\nFor the neighborhoods, the following must be known: neighborhood ID, name, population, and geometry. A neighborhood may contain several streets. A neighborhood must have at least one street.\n\nRegarding installation, the following must be known: installation code, NIF, and streetlight ID.\n\nRegarding maintenance of the streetlights, the following must be known: Tax ID (NIF), streetlight ID, and maintenance ID.\n\nAlso the entities that have spatial attributes (geom) do not need foreign keys. So some can appear disconnected from the rest of the entities.", "subreddit": "r/SQL", "upvotes": 15, "date": "[PHONE]", "source": "https://www.reddit.com/r/SQL/comments/1r4iwoq/first_time_creating_an_er_diagram_with_spatial/"}
{"prompt": "63 year old woman with an MBA, LMSW, Green Belt in Lean Six -", "completion": "63 year old woman with an MBA, LMSW, Green Belt in Lean Six -\nI'm going back to school (I never really left, Life Long Learner) to get my bachelor degree in Software Development and I already took my CCNA classes a few years ago. I am studying for my CCNA exam as well. Subnetting comes so easy to me. My background is in customer service mostly and I have done some troubleshooting in my positions and enjoyed it. I am also an author and wrote 3 children's books based on my husband's dementia. My nieces and nephews became the League of Five and their mission is to find the stolen microchip. I'm taking SQL this summer and Python in the fall. Ai tells me I will find a job easily but what do you humans in IT say? Any suggestions?", "subreddit": "r/SQL", "upvotes": 15, "date": "[PHONE]", "source": "https://www.reddit.com/r/SQL/comments/1ss87m2/63_year_old_woman_with_an_mba_lmsw_green_belt_in/"}
{"prompt": "Feeling very frustrated with the \"Use the Index, Luke\" book", "completion": "Feeling very frustrated with the \"Use the Index, Luke\" book\nHello everyone. I recently started reading \"Use the Index, Luke\" to learn about database indexes and I'm feeling incredibly frustrated right now.\n\nI'm a slow learner. I like to read technical books very slowly and draw conclusions after almost every sentence to make sure I fully grasp the concepts.\n\nIn the chapter \"Slow Indexes, Part II\", the author analyzes an execution plan. At one point he says \"The query is slow because the index lookup returns many ROWIDs\". But how did he come to that conclusion if the execution plan he just showed us only estimates 40 rows? He seemed perfectly fine with that number just a moment before! At this point I started to feel really dumb. I reread that section about 10 times. It was extremely frustrating and I almost gave up on the book entirely.\n\nEventually I kept reading and it finally made sense. We have 1000 ROWIDs in the real data but the optimizer only estimates 40. He writes \"Obviously this is a gross underestimate, as there are 1000 employees working for this subsidiary.\" Very obvious, right? But why don't we have the correct statistics in the first place? Am I just supposed to know this or blindly believe that sometimes we have statistics and sometimes we don't? What is the point of an explanation that doesn't actually explain the root cause? And right after that he says \"If we provide correct statistics...\". But how do we provide the correct statistics? Do I need to send an email to Mr. SQL with the updated numbers?\n\nAfter that he compares the cost of 680 for the indexed approach with 477 for a full table scan. But why does 477 feel okay for the user while 680 means we can't wait? I really want to know the physical why behind that.\n\nAlso at the end of the chapter he shows that creating a new index on the last name will fix everything. It will work very fast because we only have one employee with that last name. But why does the optimizer suddenly have the correct statistics this time to choose the right path? Why didn't we have them before but magically we do now?\n\nI got what the author is trying to explain and I've drawn the correct conclusions (multiple ROWIDs = bad, statistics are important, knowing your business domain is important). But wrapping my head around the way it was presented took me about 2 hours and completely drained me emotionally.\n\nWill the other chapters be just as frustrating? Is there a better or more logically structured resource on this topic?\n\nSorry for the emotional rant but my frustration level is just through the roof right now.", "subreddit": "r/SQL", "upvotes": 15, "date": "[PHONE]", "source": "https://www.reddit.com/r/SQL/comments/1s6068g/feeling_very_frustrated_with_the_use_the_index/"}
{"prompt": "SQL Server: best way to update a large table from staging without locking everything for too long?", "completion": "SQL Server: best way to update a large table from staging without locking everything for too long?\nI’m working with SQL Server and I need to update a pretty large table from a staging table after an import.\n\nMain table has a few million rows, staging table usually has somewhere between 50k–300k rows depending on the file.\n\nThe task sounds simple:\n\n* match rows by business key\n* update a few columns if values changed\n* insert rows that don’t exist yet\n\nAt first I thought “okay, just use MERGE and move on with my life,” but after reading old posts and docs, now I’m not sure if that’s the best idea.\n\nMy main worry is:\n\n* long locks\n* blocking other queries\n* updating rows that didn’t actually change\n* doing this in one huge transaction and making a mess\n\nRight now I’m thinking about something like:\n\n1. update existing rows only where values are actually different\n2. insert missing rows separately\n3. maybe do it in batches instead of one giant statement\n\nQuestions:\n\n1. Is MERGE still something people trust for this, or is separate UPDATE + INSERT still the safer choice?\n2. For a job like this, is batching usually worth it?\n3. Do you normally compare hashes / checksums, or just compare each column directly in the WHERE?\n4. Any obvious mistakes juniors make with this kind of sync process?\n\nI’m not looking for a super fancy solution, just trying to do this in a way that is correct and not accidentally rude to the database.", "subreddit": "r/SQL", "upvotes": 15, "date": "[PHONE]", "source": "https://www.reddit.com/r/SQL/comments/1s1ge4o/sql_server_best_way_to_update_a_large_table_from/"}
{"prompt": "Finished the SQL course by DataWithBaraa", "completion": "Finished the SQL course by DataWithBaraa\nI completed the SQL course by Data with Baraa a few days ago. Aside from practicing problems on sites like HackerRank, I’m not sure what do I do next. For those who took the course, what did you do afterward to level up? Should I start projects, if yes then where do I get the project ideas? or is there something else I should focus on?", "subreddit": "r/SQL", "upvotes": 15, "date": "[PHONE]", "source": "https://www.reddit.com/r/SQL/comments/1sv478f/finished_the_sql_course_by_datawithbaraa/"}
{"prompt": "Good reason to use composite keys?", "completion": "Good reason to use composite keys?\n    CREATE TABLE\n        IF NOT EXISTS CourseTag (\n            id INTEGER PRIMARY KEY,\n            courseId INTEGER NOT NULL,\n            tagId INTEGER NOT NULL,\n            UNIQUE(courseId, tagId),\n            FOREIGN KEY (courseId) REFERENCES Courses (id) ON DELETE CASCADE ON UPDATE RESTRICT,\n            FOREIGN KEY (tagId) REFERENCES Tags (id) ON DELETE CASCADE ON UPDATE RESTRICT\n        ) STRICT;", "subreddit": "r/SQL", "upvotes": 15, "date": "[PHONE]", "source": "https://www.reddit.com/r/SQL/comments/1wgw89v/good_reason_to_use_composite_keys/"}
{"prompt": "SSMS - Execute query on 300 servers", "completion": "SSMS - Execute query on 300 servers\nI'm starting to use SSMS at work, that's the only tool I have (no PowerShell cmdlet).\n\n\nI need to execute an identical SQL Query on 300 servers, but I can't find a way to do that. Could anyone point me in the right direction please ?\n\n\nSo far, I did add the 300 servers to the registered servers by tinkering to not do it manually, but when I execute the query, I only get 50 ish servers connected, then SSMS hangs and crash.", "subreddit": "r/SQL", "upvotes": 15, "date": "[PHONE]", "source": "https://www.reddit.com/r/SQL/comments/1v1ot5g/ssms_execute_query_on_300_servers/"}
{"prompt": "I built a tool that does the slow query to execution plan to index recommendation loop", "completion": "I built a tool that does the slow query to execution plan to index recommendation loop\nOver the years, I've worked with many different database engines, but every single time I had to diagnose the origin of slow queries, I ended up doing the same repetitive process over and over again:\n\n* pull query stats and sort by total time rather than mean time\n* run EXPLAIN ANALYZE on whatever comes out on top\n* go find the table definitions for everything it touches\n* check whether the column statistics are current\n* work out whether the index you have in mind already exists under another name\n* decide whether it is worth adding\n* do it again for the next query\n\nEventually I grew tired of needing to manually assemble the picture myself every single time, so I built RDST, which is a desktop database analyzer tool that currently works with both Postgres and MYSQL.\n\nRDST collapses the entire workflow shown above into one pass, so instead of starting at step one I get to the answer immediately when a slow query is detected.\n\nRDST is AI powered, but it is not random slop analysis applied to random database statistics.  The reasoning layer runs inside a fixed workflow in a semi-deterministic way, so pointing it at the same database twice gives you the same answer, which matters when you are deciding whether to add an index in production. \n\nFull disclosure - I work for Readyset (which is a caching layer for Postgres / Mysql), and this tool spawned from a recurring we had to solve for our customers - which queries should we actually cache? And these same queries are the ones that, even without a caching solution, could heavily benefit from performance diagnostics. \n\nBeyond diagnostics, RDST provides full rewrite suggestions and lets you benchmark slow queries and track their performance over time.\n\nOne other neat feature is that it also lets you ask questions about your database in plain english using NL --> SQL in a safe and secure manner with limited permissions.\n\nIt also integrates directly with Supabase, Neon, AWS RDS and DigitalOcean, making database discovery seamless.\n\nThe tool is completely free to use, and we provide free trial tokens for all of the AI powered features. The app is in beta and we plan to release it under an MIT license. It runs locally, stores locally and everything it does is read-only. Full privacy related details: [https://readyset.io/docs/readyset-ai/rdst/desktop/privacy](https://readyset.io/docs/readyset-ai/rdst/desktop/privacy)\n\nI would greatly appreciate any feedback from this community, particularly:\n\n* Does it surface the queries you'd investigate first?\n* Are its explanations and recommendations useful, or merely confident-sounding database fan fiction?\n* Is the fixed workflow the right call, or would you rather have a chat interface?\n* What's missing?\n\nSource:\n\n* [https://readyset.io/docs/readyset-ai/rdst/desktop](https://readyset.io/docs/readyset-ai/rdst/desktop)\n* [https://github.com/readysettech/rdst](https://github.com/readysettech/rdst)", "subreddit": "r/SQL", "upvotes": 15, "date": "[PHONE]", "source": "https://www.reddit.com/r/SQL/comments/1vswf1r/i_built_a_tool_that_does_the_slow_query_to/"}
{"prompt": "Optimization: Should I change the field type from VARCHAR to INT/ENUM?", "completion": "Optimization: Should I change the field type from VARCHAR to INT/ENUM?\nHello, I saw a suggestion somewhere that, for performance reasons, one should convert VARCHAR fields to INT or ENUM fields, for example.\n\nExample: I have a VARCHAR field named \"shipped,\" and it usually contains only \"yes\" or, by default, \"no.\" This is easier to read for colleagues who aren’t familiar with databases, both in the admin interface and in the query itself.\n\nFor performance reasons, does it make sense to change the column type to TINYINT() in a database with 25,000 records, using values like 0 (not sent) and 1 (sent)? Or should I use ENUM?", "subreddit": "r/SQL", "upvotes": 14, "date": "[PHONE]", "source": "https://www.reddit.com/r/SQL/comments/1rucmzf/optimization_should_i_change_the_field_type_from/"}
{"prompt": "Might be a Noob question, is turning off SQL Server fine?", "completion": "Might be a Noob question, is turning off SQL Server fine?\nI’m trying to free some memory space on my laptop, and I’ve realized that SQL server is taking up over 1.3 Gigs of ram, I’m not currently using SQL server or Visual studio to run any projects (taking a hiatus from coding) and so is shutting it down from SQL server itself fine? I’ve always kept it on start, and never shut it off as I have been coding for 8 months straight and I’m on break at the moment.\n\nIf I were to start up a project on Visual studio again, I’d need to start up SQL server again after I shut it off, right? Sorry for this Noob question, just afraid of corrupting my databases", "subreddit": "r/SQL", "upvotes": 14, "date": "[PHONE]", "source": "https://www.reddit.com/r/SQL/comments/1tffuad/might_be_a_noob_question_is_turning_off_sql/"}
{"prompt": "MySQL, MariaDB, or Postgresql for TPA Pension consulting firm?", "completion": "MySQL, MariaDB, or Postgresql for TPA Pension consulting firm?\nMy company uses superbase, a software from 1980's for relational database...\n\nOur computers are on windows 7, emulating windows xp. Safe to say our computers are dying.\n\nThe company is a TPA service for pension plans. We use superbase for client Tombstone information, work in progress, entering the clients assets, contributions, employee information etc. A lot of our work function is reliant on superbase.\n\nI am very new to this world, don't have any experience in coding and don't know anything about any of these different programs. I just want to learn so we can convert and we don't lose our entire lifeline.\n\nWe are a team of 5 people. Small firm. We have our own servers, would not want to be on cloud, need everyone to be able to access the servers at the same time as we all have different clients and need to reach information. Not sure if its possible but would love for it to work on PC desktops and remotely on mac if possible, however, not a dealbreaker.\n\nI have done some baseline research, this is what most redditors have suggested. Which would be the best for me to learn and hopefully be successful at transitioning over our information?\n\nAny help in finding a direction to go to would be very helpful.\n\nThank you in advance.\n\nIf there is any more information needed that can help you in assisting me, please comment and i'll answer!", "subreddit": "r/SQL", "upvotes": 14, "date": "[PHONE]", "source": "https://www.reddit.com/r/SQL/comments/1w3vdbe/mysql_mariadb_or_postgresql_for_tpa_pension/"}
{"prompt": "22F | How do I show my current experience to switch into a proper Data Analyst role?", "completion": "22F | How do I show my current experience to switch into a proper Data Analyst role?\nHi, I’m 22F and currently working in an engineering/manufacturing company. My current designation is Data Analyst, but honestly most of my work is in Excel and not SQL/Power BI.\n\nI have around 2+ years of experience overall.\n\nIn my current office I have made/maintained different Excel based systems like project tracker for 30+ live projects, audit log, quality tracker, material database, calibration tracker with overdue alerts, quotation/costing sheets etc.\n\nSo there is a lot of data handling, tracking, reconciliation, validation, formulas, lookups, automation and reporting involved. But I have not worked on SQL or Power BI in my actual job.\n\nBefore this I worked in IT department where I handled asset tracking and reconciliation for a large number of network devices, audit related work and vendor SLA/downtime and penalty calculations.\n\nI also have around 3 months experience in product data categorization where I worked with large amount of product data and Excel.\n\nNow I’m learning SQL by myself. Currently doing joins and next I’m going to start window functions. I’m also planning to learn Power BI and make some projects.\n\nMy main confusion is **how should I present my current experience when applying for Data Analyst jobs?**\n\nBecause my title is Data Analyst, but if recruiters see that I haven't used SQL/Power BI professionally, will they consider my experience irrelevant?\n\nShould I present my Excel work more from an analytics point of view? Like showing data cleaning, validation, reconciliation, automation, reporting, KPI tracking etc?\n\nAlso, once I learn SQL and Power BI, would it be a good idea to take some of the problems/data from my current work and create similar projects using SQL + Power BI for my portfolio? Obviously, I don't want to claim that I used SQL/Power BI at my current office when I didn't.\n\nWould really appreciate advice from people who have gone from **Excel/operations type work → SQL + Power BI → Data Analyst**.\n\nHow would you present this experience on a resume and in interviews?", "subreddit": "r/SQL", "upvotes": 14, "date": "[PHONE]", "source": "https://www.reddit.com/r/SQL/comments/1wbc7km/22f_how_do_i_show_my_current_experience_to_switch/"}
{"prompt": "Fresh grad tackling sales data integration project. Need advice", "completion": "Fresh grad tackling sales data integration project. Need advice\nHello everyone! I’ve just joined my first job at a small manufacturing firm, and I’ve been assigned a project to consolidate sales data into concise, automated reports for management.\n\nThe data currently comes in CSV and Excel files exported from an ERP system. These files are updated frequently (daily/weekly), so I’m trying to design something that’s as automated and low-maintenance as possible. One important point is that I’m the only person working on this, so simplicity and reliability matter more than enterprise-level complexity.\n\nMy current plan:\n-Set up a local PostgreSQL database\n-Load incoming CSV/Excel files into raw or staging tables\n-Clean and transform the data into a small data mart (facts and dimensions or similar)\n-Connect the final tables to Power BI for reporting\n\nI’ve done a data warehousing project at university, so I’m familiar with staging layers, dimensional modeling, and ETL concepts. That said, this is my first real production setup, and I want to avoid making design decisions now that will cause problems later.\n\nI’d really appreciate advice from more experienced folks on:\n-Whether Postgres is a good choice for this kind of small-scale setup\n-Recommended patterns or tools for automating recurring file ingestion into Postgres\n-How much modeling and structure makes sense for a small company without overengineering\n\nThe goal is something simple, reliable, and maintainable, not an enterprise-grade solution.\n\nAny feedback, suggestions, or lessons learned would be hugely appreciated. Thanks!", "subreddit": "r/SQL", "upvotes": 14, "date": "[PHONE]", "source": "https://www.reddit.com/r/SQL/comments/1qwfc7l/fresh_grad_tackling_sales_data_integration/"}
{"prompt": "How do you actually build and organize SQL projects for your portfolio?", "completion": "How do you actually build and organize SQL projects for your portfolio?\nHey everyone!\n\nI've learned SQL and practiced quite a bit, and now I want to start working on real projects for my portfolio.\n\nWhat I'm confused about is the practical side of preparing these projects.\n\nFor example, when working on a project, do you simply write SQL queries, save the scripts, and upload them to GitHub? Or is there a specific way you should organize and present everything to make it a proper portfolio project?\n\nAlso, where do you find real-world datasets to work with? I'd love to practice on realistic data rather than only databases I've created myself.\n\nI'd really appreciate hearing how you personally approach your SQL projects, from finding data to writing queries and preparing the final project for your portfolio.\n\nAny advice or examples would be really appreciated. Thank you! :)", "subreddit": "r/SQL", "upvotes": 14, "date": "[PHONE]", "source": "https://www.reddit.com/r/SQL/comments/1wo4wqc/how_do_you_actually_build_and_organize_sql/"}
{"prompt": "How do you keep database diagrams and schema documentation from going stale?", "completion": "How do you keep database diagrams and schema documentation from going stale?\nI keep seeing the same pattern across teams: the database evolves, migrations keep coming, but diagrams and schema documentation slowly stop matching reality.\n\nAt first, diagrams are accurate and useful. A few months later, they’re “mostly right.” Eventually, people stop trusting them and just inspect the database directly.\n\nI’m curious how others deal with this in practice:\n\n\\- Do you actively maintain diagrams, or accept that they’ll drift?\n\n\\- Do you rely purely on migrations / SQL as the source of truth?\n\n\\- Have you found any workflow that actually keeps schema docs useful over time?\n\nI’m especially interested in real-world setups (multiple devs, migrations, prod vs staging), not textbook answers.", "subreddit": "r/SQL", "upvotes": 14, "date": "[PHONE]", "source": "https://www.reddit.com/r/SQL/comments/1r8pmbj/how_do_you_keep_database_diagrams_and_schema/"}
{"prompt": "Curious what it's like to extract data from Vibe-Coded applications?", "completion": "Curious what it's like to extract data from Vibe-Coded applications?\nData quality for applications has already fallen off a cliff in the past decade or two as we've moved away from proper normalized backend SQL databases powering applications to under-structured JSON sludge being ubiquitous, but I'm very curious what data quality and data backends look like in the era of vibe-coded applications? Has anyone had to build a pipeline into a data warehouse or other ETL setup from a vibe-coded applications? What does the data quality and interpretability look like?\n\nI have a hypothesis that the job impacts to the Data Analytics and Data Engineering fields resulting from AI automation of folks' daily tasks will be offset by a further dip in data quality we'll see from vibe-coded applications necessitating more headcount to clean up the mess on the data side to build reporting and analytics, but I want to gather some data from professionals who may have experience with this to see if I'm right or missing the mark!", "subreddit": "r/SQL", "upvotes": 14, "date": "[PHONE]", "source": "https://www.reddit.com/r/SQL/comments/1s7741g/curious_what_its_like_to_extract_data_from/"}
{"prompt": "Best practices for safe database changes", "completion": "Best practices for safe database changes\nMost db developers end up with a few rules they never break when deploying changes. \n\nUsually after one or two painful prod incidents. \n\nOne of the first things people stop doing is editing objects directly in prod. It feels quick in the moment, tweak a column, adjust a procedure, fix something and move on. \n\nBut later someone asks what changed… and nobody really knows. \n\nSo a lot of teams switch to pushing everything through scripts instead. The script becomes the thing that gets reviewed, tested, and committed somewhere so the change can always be reproduced. \n\nAnother habit that helps a lot is generating the full deployment script first before anything runs. Sometimes tools hide what’s actually happening behind the scenes. Seeing the exact SQL that will run makes it much easier to catch things like an unexpected table rebuild or a change affecting more objects than you thought. \n\nRunning that same script in staging first is another small step that saves a lot of headaches. If something behaves differently there, it usually means staging and prod aren’t perfectly aligned. \n\nAnd one thing people learn pretty quickly is to keep a history of schema changes. When something breaks weeks later, being able to see what changed recently makes troubleshooting way easier. \n\nNone of this is complicated. It’s just the kind of discipline people pick up after a few “that looked safe” deployments.", "subreddit": "r/SQL", "upvotes": 14, "date": "[PHONE]", "source": "https://www.reddit.com/r/SQL/comments/1sgs73q/best_practices_for_safe_database_changes/"}
{"prompt": "What do you think of Pandas in Python as a SQL person?", "completion": "What do you think of Pandas in Python as a SQL person?\nI started my career in SQL, so even if I'm using Python for my ultimate data work, I'll try to do the brunt of my logic and data manipulation. in an upstream database or one of those Pandassql / Dfsql local sql packages whenever possible when working in a language like Python.\n\nHowever, what do I think of the raw functionality in Python using Pandas for SQL-esque data frame manipulation?\n\nIt's fine I guess, but quite clunky. I feel bad for any analyst who only knows about raw Pandas as a tool for SQL-style data manipulation. They are missing a universe of possibility and elegance!\n\nI generally tend to take the approach of limiting use of non-standard or unsupported languages in any corporate environment I'm working in... assuming what's available can do checking. If SQL is a standard, use that. If Python or SAS is a standard, use that. If SQL is the standard but Python is supported secondarily, I guess it's fine to use Python, but there should be a good reason. In f someone's making a request to get Python anew to solve a problem already solvable with supported tools, I'd argue that's done as a POC alongside a standard solution, not as a sole solution.", "subreddit": "r/SQL", "upvotes": 14, "date": "[PHONE]", "source": "https://www.reddit.com/r/SQL/comments/1tc9lc4/what_do_you_think_of_pandas_in_python_as_a_sql/"}
{"prompt": "I added self-hosted real-time collaboration to drawDB (SQLite + WebSockets)", "completion": "I added self-hosted real-time collaboration to drawDB (SQLite + WebSockets)\nI wanted a self-hosted ERD editor where multiple people could work on the same diagram without relying on a third-party cloud service, so I created an unofficial collaborative fork of drawDB.\n\nThis is not a new ERD editor built from scratch. It is based on the AGPL-licensed drawDB project, with a collaboration and persistence layer added on top.\n\nWhat I added:\n\n\\- Centralized diagram storage using SQLite\n\n\\- Real-time collaboration over WebSockets\n\n\\- Live table movement while another participant is dragging\n\n\\- Participant presence and collaborative cursors\n\n\\- Cursor positions mapped to diagram coordinates, so different pan/zoom states work correctly\n\n\\- Optimistic version checks to prevent stale clients from silently overwriting newer changes\n\n\\- A single Docker container for the frontend, API, WebSocket server, and SQLite storage\n\n\\- SQL import/export support inherited from drawDB, with an additional MariaDB import compatibility fix\n\nYou can run it with:\n\n    docker compose up --build\n\nThen open the same diagram URL in two browser sessions to collaborate.\n\nA current limitation is that authentication and diagram-level permissions are not implemented yet, so it should currently be deployed only on a trusted network or behind an authenticated reverse proxy.\n\nThe project is open source under AGPL-3.0:\n\n[https://github.com/yms2772/drawdb-collaborative](https://github.com/yms2772/drawdb-collaborative)", "subreddit": "r/SQL", "upvotes": 14, "date": "[PHONE]", "source": "https://www.reddit.com/r/SQL/comments/1v00k5r/i_added_selfhosted_realtime_collaboration_to/"}
{"prompt": "What’s the first thing you check when a SQL result “looks wrong”?", "completion": "What’s the first thing you check when a SQL result “looks wrong”?\nCurious how people actually debug this in production.\nSay a query runs successfully, but the number doesn’t look right.\nWhat’s your first instinct?\nCheck the filters?\nInspect the joins?\nCompare row counts?\nLook for duplicates?\nCheck NULLs?\nGo back to the source data?\nWhat’s your personal debugging sequence?", "subreddit": "r/SQL", "upvotes": 14, "date": "[PHONE]", "source": "https://www.reddit.com/r/SQL/comments/1wawi7e/whats_the_first_thing_you_check_when_a_sql_result/"}
{"prompt": "The hardest part about SQL is the data engineering. It's nonsensical", "completion": "The hardest part about SQL is the data engineering. It's nonsensical\nOne of the things that I have learned in my 7 years of experience working as a data scientist primarily in the analytics and research side of things Is that data engineering is often very convoluted; Architecture/engineering teams are generally unhelpful, and don't seem to know what they're doing, and won't explain why they do things or really help you query a huge table.\n\n**Simple example:** I want to retrieve data from a massive set of tables in BigQuery that have billions of rows each. One of them is partitioned and clustered, where the partition is by the date. One of these sister tables only has a cluster on the year, but has no partitioning on date. OK, that's weird. Why is it not partitioned by any date fields at all? To prevent unnecessary shuffling, I selected one of the date fields, the order date. I mean surely that should be used to filter down the data right? It didn't help at all. Joining to this table even with the date field still results in shuffling and repartitioning of the data massively, so I asked the architecture team why they did that and there was no real answer. No real instruction or guidance or advice. Just query that thing, run that SQL. That's basically the advice I was given. Who cares about the cost right? That doesn't make sense to me\n\nSo I thought, OK I'll just ask one of our high powered AI models and one of the agents they set up. The agent Started telling me the architecture doesn't make any sense, that it's wasteful and inefficient to retrieve data from such a huge table and went back and forth on several solutions like creating a temp table, creating a permanent table, you should cross join XYZ. None of it made any sense. So the data engineering part of this simple example, retrieving data on a table that isn't partitioned or well clustered ends up with a huge shuffle and explosion of data\n\n**No experts remain**. One consequence of absurd series of layoffs that big companies keep doing, supposedly replacing people with offshore labor and AI agents, is that there are no more experts anymore. There are teams that handle analytics and architecture and stuff, but they don't really seem to care about anything. No passionate experts who really understand the data, no product managers who can help you really tap into the kind of insights you want. It's like a big empty city that you have to go to and wander around in, Where there's no one actually there to help you. It's pure nonsense really.", "subreddit": "r/SQL", "upvotes": 14, "date": "[PHONE]", "source": "https://www.reddit.com/r/SQL/comments/1rctigo/the_hardest_part_about_sql_is_the_data/"}
{"prompt": "Is my resume look good for a 2026 resume to break into entry level data analytics?", "completion": "Is my resume look good for a 2026 resume to break into entry level data analytics?\nBelow is my resume. This is what I learned in school/what I am learning now. I am trying to memorize syntax for SQL, Excel and Python so I can be able to debug it whenever an AI gets it wrong. I am also trying to relearn terminology like diagnostics and predictive analytics. Is there anything that I should add or take away. I understand that SQL and python are important for data analytics and appear in a lot of job descriptions but in 2026, is having an entire project of the two important? Is the AI work I have enough or do I need to learn more about it?\n\n**Name**\n\n*Data Analyst  |  SQL · Python · Power BI · Tableau  |  Healthcare · Financial Services · Manufacturing*\n\n**EDUCATION**\n\n**College** |  B.S. Management Information Systems  |  GPA: 3.48  |  Dean’s List: 6 Semesters May 2024\n\n**DATA ANALYTICS PROJECTS**\n\n**AI-Assisted Analytics Project  –**  *Integrated generative AI tools into data analysis and reporting workflows*\n\n* Applied AI literacy and familiarity using ChatGPT for data analysis via prompt engineering for data tasks, producing AI assisted reporting and automated insight generation on structured datasets\n* Leveraged Microsoft Copilot and generative AI tools experience to streamline data reporting tools and workflows, improving data-driven decision making and reducing manual effort in report automation\n\n**SQL Analytics Project  –**  *Queried and analyzed 200,000+ records across a multi-relational PostgreSQL and MySQL database*\n\n* Used JOINs, CTEs, window functions, and aggregate functions for KPI trend analysis across related tables; applied PL/SQL procedural logic and Microsoft SQL Server schema management for data governance and data integrity\n* Executed DDL, DML, DCL, and TCL commands for database management and data warehousing operations; performed data profiling and root cause analysis to identify data quality issues and reduce downstream reporting errors\n\n**Business Intelligence Project  –**  *Built multi-tool dashboards in Power BI, Tableau, and Looker for stakeholder reporting*\n\n* Designed ETL pipeline in Power Query for data cleaning and transformation of raw clothing store data; built star schema data model with fact and dimension tables enabling KPI tracking and operational reporting\n* Led dashboard development in Power BI (DAX measures) and Tableau for storytelling with data on sales trends; explored Looker for ad hoc report navigation and data visualization for theoretical stakeholder decision making\n\n**Advanced Spreadsheet Project  –**  *Data scrubbing and regional sales analysis across Microsoft Excel and Google Sheets*\n\n* Cleaned and transformed data using TRIM, MID, and TEXTJOIN; applied VLOOKUP, XLOOKUP, and lookup functions via INDEX/MATCH formulas for multi-region comparative analysis and data interpretation of revenue performance\n* Designed SUMIFS, COUNTIFS, and AVERAGEIFS formulas with conditional formatting in Google Sheets for operational analytics, scenario analysis, forecasting, and benchmarking to support data-driven decision making\n\n**Python Analytics Project  –**  *Statistical analysis and data visualization on sales data using Python*\n\n* Performed data wrangling and descriptive statistics using Python with Pandas and NumPy; applied statistical analysis including regression analysis, variance analysis, hypothesis testing, and time series analysis on sales datasets\n* Built Matplotlib data visualization charts fo", "subreddit": "r/SQL", "upvotes": 14, "date": "[PHONE]", "source": "https://www.reddit.com/r/SQL/comments/1rymxpu/is_my_resume_look_good_for_a_2026_resume_to_break/"}
{"prompt": "SQL SIDE QUEST - An Immersive story-telling SQL Game. Chapter 3 is out!", "completion": "SQL SIDE QUEST -  An Immersive story-telling SQL Game. Chapter 3 is out!\n\n [https://www.sqlsidequest.com/](https://www.sqlsidequest.com/) CHAPTER 3 IS NOW LIVE!\n\nLast year in Dec 2025 I released SQL SIDE QUEST which took over 3 years to build. I wanted to create an immersive story-telling way to learn and practice SQL, and hence sql side quest was born. Its completely free, browser-based, no signup. Been solo on it the whole time. Looking forward for your feedback :) Cheers and Enjoy", "subreddit": "r/SQL", "upvotes": 14, "date": "[PHONE]", "source": "https://www.reddit.com/r/SQL/comments/1vrpyf2/sql_side_quest_an_immersive_storytelling_sql_game/"}
{"prompt": "Snowflake or Databricks for Data Analysts?", "completion": "Snowflake or Databricks for Data Analysts?\nWhich platform is more widely used for data analyst roles: Snowflake or Databricks?\n\nIf you could learn only one first, which would you choose and why? I'm particularly interested in which one is more commonly used in day-to-day analytics work across companies.", "subreddit": "r/SQL", "upvotes": 13, "date": "[PHONE]", "source": "https://www.reddit.com/r/SQL/comments/1umc08c/snowflake_or_databricks_for_data_analysts/"}
{"prompt": "SQL questions for junior data analyst", "completion": "SQL questions for junior data analyst\nHi everyone,\nI have an upcoming interview for a Junior Data Analyst role and wanted to ask what kind of SQL questions are typically asked at this level.\n\nFrom your experience:-\n\n* What SQL topics are most commonly tested?\n* Are interviews usually more theory-based or hands-on query writing?\n* Any common or tricky SQL questions I should prepare for?", "subreddit": "r/SQL", "upvotes": 13, "date": "[PHONE]", "source": "https://www.reddit.com/r/SQL/comments/1q8h221/sql_questions_for_junior_data_analyst/"}
{"prompt": "Am absolutely dumbfounded on how to make this SQL based program function", "completion": "Am absolutely dumbfounded on how to make this SQL based program function\nHello all.  I apologize if this is the wrong sub or place to ask for help.  I have never dealt with an installation such as this and the company who made this is no longer available for support.\n\nBasically this client who owns an alarm company had a RAID configuration crap out on him.  I recovered the array however he needs this ancient and now unsupported program to run in order to get his client data off.\n\nI found this manual and attempted to follow the instructions to a \"T\".  But am hitting dead ends.\n\nFrom what I tried as per setup guidelines:\n\n\\- Installed SQL Anywhere studio.  Informed me 32-bit was not compatible but installed drivers.\n\\- Installed the Server and Client application on my Local PC.\n\\- Shared the installation directory on Network.\n\\- Mapped the folder to a drive.\n\\- Created and modified the shortcut to start on said drive.\n\nAfter this I keep getting a disk error and not able to find any log files.  There is also an \"SQLSETUP\" exe that asks me for parameters such as server name, database name, user id, pass, protocol, etc.\n\nMy goal is to get this set up locally somehow without a network.  But I am absolutely dumbfounded.  I attached photos of the installation instructions in case someone can spot an error somewhere.  Any help is greatly appreciated.\n\nOR:\n\nIs there any way to extract the data off of the backed up database files with an external program?", "subreddit": "r/SQL", "upvotes": 13, "date": "[PHONE]", "source": "https://www.reddit.com/r/SQL/comments/1sfznpn/am_absolutely_dumbfounded_on_how_to_make_this_sql/"}
{"prompt": "Looking for a Study Partner for Data Analyst / SQL Developer Job Prep", "completion": "Looking for a Study Partner for Data Analyst / SQL Developer Job Prep\nHi everyone,\n\nI’m currently working as a Finance Analyst (Intern) in Bengaluru and preparing to switch into a **Data Analyst / SQL Developer** role.\n\nLooking for a serious study/accountability partner who is also preparing for similar roles. Mainly focusing on **SQL, Power BI, Excel, Python, data engineering concepts ,interview prep, projects, and job applications**.\n\nWe can study together, share resources and job openings, practice interview questions, and keep each other consistent.\n\nIf you're actively preparing for Data Analyst / BI / SQL roles and interested, feel free to DM me.", "subreddit": "r/SQL", "upvotes": 13, "date": "[PHONE]", "source": "https://www.reddit.com/r/SQL/comments/1wcbrum/looking_for_a_study_partner_for_data_analyst_sql/"}
{"prompt": "Portabase v1.2.9 – open-source database backup/restore tool, now supporting SQLite", "completion": "Portabase v1.2.9 – open-source database backup/restore tool, now supporting SQLite\nHi all :)\n\nI am one of the maintainers of [**Portabase**](https://portabase.io/?utm_source=reddit&utm_medium=referral&utm_campaign=release_1_2_9&utm_content=r_sql), and I am excited to share some news: we now support SQLite backup and restoration!\n\nHere is the repository:\n[https://github.com/Portabase/portabase](https://github.com/Portabase/portabase)\n\nQuick recap of what Portabase is:\n\nPortabase is an open-source, self-hosted **database backup and restore tool**, designed for simple and reliable operations without heavy dependencies. It runs with a central server and lightweight agents deployed on edge nodes (e.g. Portainer), so databases do not need to be exposed on a public network.\n\n**Key features:**\n\n* Logical backups for **PostgreSQL**, **MySQL, MariaDB, MongoDB and now SQLite**\n* Integrations with multiple backend storages: **local filesystem, S3, Cloudflare R2**\n* Integrations with multiple notification systems: **Discord, Telegram, Slack, etc.**\n* Cron-based scheduling and multiple retention strategies\n* Agent-based architecture suitable for self-hosted and edge environments\n* Ready-to-use Docker Compose setup\n\n# What’s new since the last update\n\n* **S3 bug fixes** — now fully compatible with AWS S3 and Cloudflare R2\n* **Backup compression with optional AES-GCM encryption**\n* **Full streaming uploads** (no more in-memory buffering, which was not suitable for large backups)\n* **SQLite support**\n\n# What’s coming next\n\n* **OIDC** support in the near future\n* **Redis** support\n\nFeedback is welcome. Please open an issue if you encounter any problems.\n\nThanks all!", "subreddit": "r/SQL", "upvotes": 13, "date": "[PHONE]", "source": "https://www.reddit.com/r/SQL/comments/1rdgu5z/portabase_v129_opensource_database_backuprestore/"}
{"prompt": "I dont completely understand the structure of this query.", "completion": "I dont completely understand the structure of this query.\nSELECT productName, quantityInStock\\*buyPrice AS Stock, quantityInStock\\*buyPrice/(totalValue)\\*100\n\nAS Percent\n\nFROM Products,(\n\nSELECT SUM(quantityInStock\\*buyPrice) AS totalValue FROM Products) AS T\n\nORDER BY quantityInStock\\*buyPrice/(totalValue)\\*100 DESC\n\n;\n\n\nIs this a subquery? If so what kind?", "subreddit": "r/SQL", "upvotes": 13, "date": "[PHONE]", "source": "https://www.reddit.com/r/SQL/comments/1rvf1x4/i_dont_completely_understand_the_structure_of/"}
{"prompt": "First corporate data role and flying completely solo. Need advice pls.", "completion": "First corporate data role and flying completely solo. Need advice pls.\nHello everyone! I'm 40 days into my first corporate data role and I'd love some tips, advice, or literally any form of feedback.\n\nI am the only data person in a mid sized manufacturing firm, which also means no team, no senior and absolutely no one to tell me if my approach is right or if I'm completely out of my mind for even attempting this. Just me, a laptop that's about to commit seppuku at any given moment, and sheer determination. Here's what I've managed to build so far:\n\nAirflow DAGs to ingest data from our ERP system into the database\n\nPostgreSQL database structured with raw, staging, dimension, and fact layers\n\nA demo BI dashboard that I cannot publish because I am currently at the begging management on my knees stage of expensing a Power BI pro subscription plan\n\nI'm also in the process of moving Postgres to the company server, pleading with tears in my eyes for a hardware upgrade and planning to bring in dbt core for transformations. I have some experience with dbt cloud from university, so I'm either going to nail this or spectacularly shit the bed, honestly idk.\n\nI'll eventually need to scale this across multiple departments as a solo data person, so any feedback or words of comfort would be greatly appreciated. Thanks!", "subreddit": "r/SQL", "upvotes": 13, "date": "[PHONE]", "source": "https://www.reddit.com/r/SQL/comments/1rsrrf2/first_corporate_data_role_and_flying_completely/"}
{"prompt": "Absolutely puzzled with this Bigquery result", "completion": "Absolutely puzzled with this Bigquery result\nI have this query in Bigquery:\n\n    SELECT column1, column2, count(*)\n    FROM table\n    GROUP BY column1, column2\n    HAVING COUNT(*) >\n     1\n\nWhen I run it, I get no data as a result, so no duplicates in the table.\n\nHowever, if I run this\n\n    SELECT count(*)\n    FROM (\n     SELECT column1, column2, count(*)\n     FROM table\n     GROUP BY column1, column2\n     HAVING COUNT(*) >\n     1\n    )\n\nThe result is 470548, meaning every single row in the table. Why? I would expect to get 0 or null, since the subquery has no result at all.", "subreddit": "r/SQL", "upvotes": 13, "date": "[PHONE]", "source": "https://www.reddit.com/r/SQL/comments/1tpwp14/absolutely_puzzled_with_this_bigquery_result/"}
{"prompt": "How to Fix Slow MySQL Queries? looking for real advise", "completion": "How to Fix Slow MySQL Queries? looking for real advise\nI’ve been trying to improve the performance of a MySQL database for a project, and I’m curious how others usually approach slow queries.\n\nThe database isn’t huge (a few million rows), but some pages have become noticeably slower over time. A couple of SELECT queries that used to finish almost instantly are now taking several seconds, especially when multiple users are active.\n\nSo far, I’ve tried:\n\n* Running `EXPLAIN` to understand the execution plan.\n* Adding indexes on columns used in `WHERE` and `JOIN` conditions.\n* Removing unnecessary `SELECT *` statements.\n* Optimizing a few JOINs.\n* Checking the slow query log.\n\nThings improved a bit, but I still feel like I’m missing something.\n\nFor those who regularly work with MySQL:\n\n* What’s the first thing you check when a query becomes slow?\n* Have you found any optimization techniques that made a huge difference?\n* Do you rely on tools besides `EXPLAIN`?\n* At what point do you decide it's a database design problem instead of just a query problem?\n\nI’d really like to hear real experiences rather than generic tips. Sometimes a small change ends up making a massive difference, and I'm wondering if there's something I haven't considered yet.\n\nLooking forward to hearing what has worked for you!", "subreddit": "r/SQL", "upvotes": 13, "date": "[PHONE]", "source": "https://www.reddit.com/r/SQL/comments/1uri28a/how_to_fix_slow_mysql_queries_looking_for_real/"}
{"prompt": "How does Postgres process your queries?", "completion": "How does Postgres process your queries?\nWhenever a backend process receives a query to process, it passes through 5 phases.\n\n1. `Parser:` parse the query into a parse tree\n2. `Analyzer:` do semantic analysis and generate a query tree\n3. `Rewriter:` transfer it using rules if you have any\n4. `Planner:` generate a cost-effective plan\n5. `Executor:` execute the plan to generate the result\n\n# 1. Parser\n\nThe parser parses the query into a tree-like structure, and the root node will be the `SelectStmt`.\n\nIts main functionality is to check the syntax, not the semantics of it.\n\nThat means, if your syntax is wrong, the error will be thrown from here, but if you make some semantic error, i.e. using a table that doesn't exist, it will not throw an error.\n\n# 2. Analyzer\n\nThe analyzer takes the parsed tree as input, analyzes it and forms a query tree.\n\nHere, all semantics of your query are being checked, like whether the table name exists or not.\n\nThe main components of a query tree are:\n\n1. `targetlist:` the list of columns or expressions we want in our result set. If you use the `*` sign here, it will be replaced by all columns explicitly.\n2. `rengetable:` the list of all relations that are being used in the query. It also holds information like the OID and the name of the tables.\n3. `jointree:` it holds the `FROM` and `WHERE` clause. It also contains information about your `JOIN` strategies with `ON` or `USING` conditions.\n4. `sortclause:` the list of sorting clauses\n\nWhile the query tree has more components, these are some primary ones.\n\n# 3. Rewriter\n\nRewriter transforms your query tree using the rule system you have defined.\n\nYou can check your rules using the `pg_rules` system view.\n\nFor example, it attaches your views as a subquery.\n\n# 4. Planner\n\nThe planner receives a query tree as input and tries to find a cost-efficient query plan to execute it.\n\nThe planner in Postgres uses a cost-based optimisation instead of a rule-based optimisation.\n\nYou can use the `EXPLAIN` command to see the query plan.\n\nIn the tree form, it has a parent node where the tree starts, called `PlannedStmt`.\n\nIn child nodes, we have interlinked plan nodes, which are executed in a bottom-up approach. That means, it will execute the SqeScan node first, then SortNode.\n\n# 5. Executor\n\nUsing the plan tree, the executor will start executing the query.\n\nIt will allocate some memory areas, like `temp_buffers` and `work_mem`, in advance to store the temporary tables if needed.\n\nIt uses `MVCC` to maintain consistency and isolation for transactions.\n\n\\-------------------------------------\n\nHi everyone,\n\nI am Abinash. I am currently studying Postgres Internals. I regularly read docs and make some notes. I hope you find it valuable.\n\nIf you are interested, please let me know.\n\nThank you.", "subreddit": "r/SQL", "upvotes": 12, "date": "[PHONE]", "source": "https://www.reddit.com/r/SQL/comments/1q7ipcl/how_does_postgres_process_your_queries/"}
{"prompt": "How do you handle data quality and validation in SQL workflows?", "completion": "How do you handle data quality and validation in SQL workflows?\nHey all,\n\nI’m part of a student team from the University of Minnesota and the University of Michigan researching **data quality and validation in SQL-based workflows**.\n\nI’m curious how people are handling this in practice — things like:\n\n* writing validation queries or checks\n* catching data integrity issues early\n* keeping datasets clean over time\n\nWould love to hear what approaches, patterns, or pain points you’ve run into.\n\nIf you’re open to sharing more structured input, we also put together a short survey (\\~10–15 min):\n[https://umn.qualtrics.com/jfe/form/SV\\_3QVlUfLaV30AFKe](https://umn.qualtrics.com/jfe/form/SV_3QVlUfLaV30AFKe)\n\nHappy to share a summary of what we find back with the community.\n\nThanks!", "subreddit": "r/SQL", "upvotes": 12, "date": "[PHONE]", "source": "https://www.reddit.com/r/SQL/comments/1se555f/how_do_you_handle_data_quality_and_validation_in/"}
{"prompt": "Concatenate Multiple rows in to a single field within a select statement with multiple joins", "completion": "Concatenate Multiple rows in to a single field within a select statement with multiple joins\nNot sure if my title conveys the issue properly but let me try to explain.\n\n\nEssentially i am trying to join multiple tables to return data. that is all fine for fields that have pretty much one to one with row, but there is a certain table that I would need multiple rows that belong to a certain key returned in one field. To add to this, i would only want to return rows that have a certain flag set.\n\nSo given the above tables, id want it to return\n\nSite A     A,B,D\n\nSite B      G\n\n\nThis is all within an already established Select Statement with multiple where joins. Not sure if that matters. So there is other data I need output, however i need this i addition to those statement.", "subreddit": "r/SQL", "upvotes": 12, "date": "[PHONE]", "source": "https://www.reddit.com/r/SQL/comments/1uy989d/concatenate_multiple_rows_in_to_a_single_field/"}
{"prompt": "How do you QC your new queries?", "completion": "How do you QC your new queries?\nWe have some really old software which produces cubes that our analysts use. And I use them as well to double check my work after creating complex new queries. It’s amazing how often I’ll realise I’ve done something silly after I’ve checked it in a cube.\n\nI’m just wondering what other people do to sense check their results?  When you have a beast of a query full of things like running totals split by regions, or growth patterns, something a bit fiddly that could harbour an error.", "subreddit": "r/SQL", "upvotes": 12, "date": "[PHONE]", "source": "https://www.reddit.com/r/SQL/comments/1rdb04r/how_do_you_qc_your_new_queries/"}
{"prompt": "Can you find missing records when both tables have duplicates and neither table has a primary key?", "completion": "Can you find missing records when both tables have duplicates and neither table has a primary key?\nYou have Source and Target tables with millions of rows.\n\n* Neither table has a primary key.\n* Both tables can contain duplicate rows.\n* Some rows may be missing from Target.\n* Some extra rows may exist in Target.\n* `EXCEPT` doesn't show the complete picture when duplicate counts matter.\n\nFor example:\nSource:  A, A, A, B, B, C\nTarget:  A, A, B, B, B, C\n\nBoth contain the same values, but the duplicate counts are different.\n\nWhat SQL approach would you use to identify exactly which records are missing, extra, or have different counts?", "subreddit": "r/SQL", "upvotes": 12, "date": "[PHONE]", "source": "https://www.reddit.com/r/SQL/comments/1wtfym5/can_you_find_missing_records_when_both_tables/"}
{"prompt": "Platform for SQL Contribution", "completion": "Platform for SQL Contribution\nI am coming from Data Science background and completed my masters in it. I have good understanding of SQL and I am looking for opensource contribution from where I get real world experience of Queries.\n\nDoes any one knows from where I can get or any platform.\n\nThanks ✨️ in advance", "subreddit": "r/SQL", "upvotes": 12, "date": "[PHONE]", "source": "https://www.reddit.com/r/SQL/comments/1uccyih/platform_for_sql_contribution/"}
{"prompt": "Shebang equivalent for SQL dialects?", "completion": "Shebang equivalent for SQL dialects?\nWhen writing shell scripts it's common to have on line 1\n\n    #!/bin/bash\n\nwhich would differentiate it from\n\n    #!/bin/sh\n\nI have a lot of SQL saved in text files — all ```.sql``` extension — for processing CSVs at work; these are all in-memory instances that ingest CSVs and output CSVs. For many years I only used SQLite so I only had to remember ```sqlite3 < query.sql```.\n\nRecently, I started writing for DuckDB as well, initially only because of its ability to load JSON/CSV from a URL; I'm also quickly seeing how advantageous its extra functions are.\n\nIs there any shebang-style line that I can start my files with, or do I just need to write a freetext comment like this?\n\n    -- This is for DuckDB", "subreddit": "r/SQL", "upvotes": 12, "date": "[PHONE]", "source": "https://www.reddit.com/r/SQL/comments/1vmfpzx/shebang_equivalent_for_sql_dialects/"}
{"prompt": "how to standardize this date column in mysql?", "completion": "how to standardize this date column in mysql?\n|ship\\_date|**delivery\\_date**|\n|:-|:-|\n||\n|Feb 10 2024|Feb 15 2024|\n|[PHONE]|[PHONE]|\n|[PHONE]|[PHONE]|\n|01/15/2024|01/19/2024|", "subreddit": "r/SQL", "upvotes": 12, "date": "[PHONE]", "source": "https://www.reddit.com/r/SQL/comments/1w6a8x7/how_to_standardize_this_date_column_in_mysql/"}
{"prompt": "SQL at work (trying to understand)", "completion": "SQL at work (trying to understand)\nHiya\n\nI am a data analyst and statistician, I work in big data and statistical analysis etc.. however I'm looking to move roles into a data scientist role.\n\nI've been in my role for 9 years and used R, python, SPSS and Excel. The roles I'm looking for ALL ask for SQL.! I have never used it in my role. So currently I am bridging the gaps on datacamp and online resources.\n\nMy question is... Who uses SQL and how it works at source? How would I use it in my current role? (I've never had the need to!?) In my day job, I am given CSV files or get data from cloud, then clean and analyse etc. So for the new job roles out there, are they merging all jobs into one eg data analyst, scientist and engineer. Or does my current workplace broken down these roles, or because I can get it from the database direct, I don't need to use SQL? Has the market evolved?\n\nAnd there are so many different SQLs to learn. Are they that different? Which do you recommend?\n\nJust confused a bit about this. Especially the fact it is a requirement on every JD. I feel like it's a core area and ask myself how am I a data analyst without it!\n\nHope that was clear-ish!\n\nMany thanks!", "subreddit": "r/SQL", "upvotes": 11, "date": "[PHONE]", "source": "https://www.reddit.com/r/SQL/comments/1qnca7u/sql_at_work_trying_to_understand/"}
{"prompt": "Benchmarked SQLite 11 ways: ORM is the bottleneck, not the database", "completion": "Benchmarked SQLite 11 ways: ORM is the bottleneck, not the database\nBenchmarked SQLite write performance 11 ways and the result was not what I expected. The database wasn't the bottleneck. The ORM was. Raw sqlite3.executemany hits 88K r/s. SQLAlchemy caps at 3,800.\n\nThe ORM throughput stays flat from 3M rows to 50M rows — it's so slow it never even touches SQLite's actual I/O scaling curve. The raw path drops 25% over the same range because it actually hits B-tree depth and WAL checkpoint costs.\n\nFull breakdown with industry comparison (Expensify 4M QPS, Litestream, Cloudflare D1) in the post.", "subreddit": "r/SQL", "upvotes": 11, "date": "[PHONE]", "source": "https://www.reddit.com/r/SQL/comments/1tm9j1c/benchmarked_sqlite_11_ways_orm_is_the_bottleneck/"}
{"prompt": "How do you promote data changes from dev to prod, not just schema?", "completion": "How do you promote data changes from dev to prod, not just schema?\nSchema changes are a solved problem for us with migrations. What I keep running into is the data side. If someone changes lookup values, config rows, or reference tables in dev, there's no clean way to carry that to prod along with the migration.\n\nHow does your team handle this today? Curious whether it's seed scripts, manual dumps, some diff tool, or you just don't let data change outside of prod in the first place.", "subreddit": "r/SQL", "upvotes": 11, "date": "[PHONE]", "source": "https://www.reddit.com/r/SQL/comments/1waci9g/how_do_you_promote_data_changes_from_dev_to_prod/"}
{"prompt": "Why did the COUNT() as window function produce this output in MySQL Workbench 8.0?", "completion": "Why did the COUNT() as window function produce this output in MySQL Workbench 8.0?\nHey SQLers 🙋‍♂️\n\nI once used COUNT() as a window function in MySQL Workbench 8.0 on a table 'employees' that had only two columns: 'deptid' and 'mgrid' both of INT type, none of them being keys. The table had 10 rows in random order.\n\nOn running the query, the output was as shown in the snapshot attached below.\n\nTill date I have not understood how this query is working to produce such an output.\n\nSomeone enlighten me please.", "subreddit": "r/SQL", "upvotes": 11, "date": "[PHONE]", "source": "https://www.reddit.com/r/SQL/comments/1rzn7tx/why_did_the_count_as_window_function_produce_this/"}
{"prompt": "How can I generate \"create script\" for ALL databases in a server?", "completion": "How can I generate \"create script\" for ALL databases in a server?\nHey!\nI know there are options to generate a create script for one database in SSMS, but if I want to recreate a whole db server as close as possible with all databases, tables etc including permissions and so on, how can I do that? I would appreciate if someone could point me in the right direction as I am no expert in SQL.\nThanks in advance!", "subreddit": "r/SQL", "upvotes": 11, "date": "[PHONE]", "source": "https://www.reddit.com/r/SQL/comments/1tr16ck/how_can_i_generate_create_script_for_all/"}
{"prompt": "Platforms to practice SQL", "completion": "Platforms to practice SQL\nI have completed my graduation and have been practicing SQL from a while including stored procedures , triggers.\n\nI want to know what are some certifications that i have to do it or any good platforms to practice/solve and get certifications\n\nor should I do some projects (pls tell me if u know what type of projects )\n\nThank you", "subreddit": "r/SQL", "upvotes": 11, "date": "[PHONE]", "source": "https://www.reddit.com/r/SQL/comments/1tig31t/platforms_to_practice_sql/"}
{"prompt": "Neon vs self hosted PosrgreSQL", "completion": "Neon vs self hosted PosrgreSQL\nFor folks who have recently or previously switched to Neon, what are some of the drawbacks and advantages you see in real production use cases as compared to Postgres?", "subreddit": "r/SQL", "upvotes": 11, "date": "[PHONE]", "source": "https://www.reddit.com/r/SQL/comments/1uwasuh/neon_vs_self_hosted_posrgresql/"}
{"prompt": "22F, feeling stuck in my career. Need honest advice to switch into Data Analytics by October.", "completion": "22F, feeling stuck in my career. Need honest advice to switch into Data Analytics by October.\nHi everyone,\n\nI'm 22F and honestly feeling very confused about my career right now. I really need some genuine guidance from people already working in data analytics.\n\nA little background:\n\n* My first job was at **Contexio** as a Research Analyst. It was mostly Excel-based work for apparel clients like Tata CLiQ brands (Adidas, Sweet Dreams, Freakins, etc.). I used to maintain product data, image sequencing, detailing, backend updates, and Excel sheets. Salary was **14k/month**.\n* Then I joined **HDFC Bank** as an IT Officer. I was there for around a year. My work included ServiceNow, coordinating with data vendors, PO-related work, SLA tracking, monthly reporting, CIP closures, documentation, and operations. It wasn't a pure technical role but involved handling data and processes. My package was **2.4 LPA**.\n* Currently I'm working in a manufacturing company (Chintamani Thermal). I joined because I thought I'd get exposure to SQL, Power BI, or analytics. But after joining I realized it's mostly VBA and documentation work. There is almost no SQL, Power BI, or actual analytics here. My current package is **3.12 LPA**.\n\nNow I want to switch into a proper **Data Analyst** role by **October**.\n\nI have already started learning SQL (currently following the 30-hour Baraa SQL course on YouTube). I already know the basics of Power BI, but I know that's probably not enough.\n\nMy questions are:\n\n1. Considering my background, can I realistically get a Data Analyst role by October?\n2. Apart from SQL and Power BI, what should I focus on?\n3. Should I learn Python now or first become really strong in SQL?\n4. What kind of projects should I build to compensate for not having analytics experience?\n5. Should I start applying immediately or wait until I've completed SQL?\n6. Is my previous experience relevant enough for recruiters, or should I present it differently on my resume?\n\nI'm honestly feeling stressed because I don't see any future in my current role, and I don't want to waste another year.\n\nI'd really appreciate honest advice, roadmap suggestions, or if someone has switched into data analytics from a similar background.\n\nThanks in advance.", "subreddit": "r/SQL", "upvotes": 11, "date": "[PHONE]", "source": "https://www.reddit.com/r/SQL/comments/1ukgoa5/22f_feeling_stuck_in_my_career_need_honest_advice/"}
{"prompt": "How do you catch Spark SQL environment differences before staging blows up (Databricks → EMR)?", "completion": "How do you catch Spark SQL environment differences before staging blows up (Databricks → EMR)?\nMoved a Spark SQL job from Databricks to EMR this week. Same code, same data, same query.\n\nDev environment finished in 50 minutes. EMR staging was still running after 3 hours.\n\nWe spent hours in the Spark UI looking at stages, task timings, shuffle bytes, partition counts, and execution plans. Partition sizes looked off, shuffle numbers were different, task distribution was uneven, but nothing clearly pointed to one root cause in the SQL.\n\nWe still don't fully understand what happened. Our best guess is Databricks does some behind-the-scenes optimization (AQE, adaptive join, caching, or default configs) that EMR doesn't apply out of the box. But we couldn't confirm it from logs or UI alone.\n\nWhat am I doing wrong?", "subreddit": "r/SQL", "upvotes": 11, "date": "[PHONE]", "source": "https://www.reddit.com/r/SQL/comments/1rf5rmq/how_do_you_catch_spark_sql_environment/"}
{"prompt": "Connecting salesforce, netsuite, and zendesk data to our postgres warehouse but the nested json is killing our sql queries", "completion": "Connecting salesforce, netsuite, and zendesk data to our postgres warehouse but the nested json is killing our sql queries\nOur warehouse runs on postgres and we're loading data from a bunch of saas tools. The problem is a lot of these sources dump deeply nested json into our tables and writing sql against it is becoming a real headache for the BI team. For example our salesforce data has custom objects nested three levels deep and our zendesk data has ticket fields with arrays of custom field values inside json blobs. Every query turns into a chain of json\\_extract\\_path\\_text and jsonb\\_array\\_elements calls that makes the sql basically unreadable for anyone who isn't deeply familiar with postgres json functions.\n\nThe analysts on my team know sql well but they shouldn't need to understand json parsing just to pull a customer satisfaction score. We've been creating views that flatten everything but that's a ton of upfront work and the views break when the source schema changes. I keep hearing that some ingestion tools flatten and normalize the data before it lands in the warehouse which would solve this entirely. Anyone dealt with this json nesting problem and found a good approach? Is it better to fix at ingestion time or at the modeling layer with dbt or something similar?", "subreddit": "r/SQL", "upvotes": 11, "date": "[PHONE]", "source": "https://www.reddit.com/r/SQL/comments/1rf3ikn/connecting_salesforce_netsuite_and_zendesk_data/"}
{"prompt": "Best websites to practice SQL to prep for technical interviews?", "completion": "Best websites to practice SQL to prep for technical interviews?\nWhat do you all think is the best website to practice SQL specifically for interview purposes? Basically to pass technical tests you get in interviews, for me this would be mid-level data analyst / analytics engineer roles\n\nI've tried Leetcode, Stratascratch, DataLemur so far. I like stratascratch and datalemur over leetcode as it feels more practical most of the time\n\nany other platforms I should consider practicing on that you see problems/concepts on pop up in your interviews?", "subreddit": "r/SQL", "upvotes": 11, "date": "[PHONE]", "source": "https://www.reddit.com/r/SQL/comments/1r6m24e/best_websites_to_practice_sql_to_prep_for/"}
{"prompt": "SQL Dev vs SQL Architect", "completion": "SQL Dev vs SQL Architect\nSo I've been a support dev, a dba and an actually developer and a technical consultant in different jobs. I found out I'm being laid off as part of a larger restructuring at my current company. So I got my stuff together and started applying and interviewing. Took a while and finally I got a nibble after applying for a SQL DBA job.\n\nThey seem to like me, but then they said I would be a better fit as a SQL architect. They insist I'm a great candidate as all my SQL work was external facing so I was dealing with clients.\n\nOn paper, I agree, and there is training during onboarding so I'm not worried about dropping in blind. I'm just having a hard time picturing the day to day.\n\nCan anyone offer their experience?", "subreddit": "r/SQL", "upvotes": 11, "date": "[PHONE]", "source": "https://www.reddit.com/r/SQL/comments/1vywxub/sql_dev_vs_sql_architect/"}
{"prompt": "What is the best storage option for uploading and downloading large HD images?", "completion": "What is the best storage option for uploading and downloading large HD images?\nHi everyone,\n\nI’m building an application where users will upload and download large numbers of high-resolution images.\n\nWhich storage service would be best for this use case in terms of upload speed, download speed, cost, security, and scalability", "subreddit": "r/SQL", "upvotes": 11, "date": "[PHONE]", "source": "https://www.reddit.com/r/SQL/comments/1wdayla/what_is_the_best_storage_option_for_uploading_and/"}
{"prompt": "How do you validate complex queries before running them on production?", "completion": "How do you validate complex queries before running them on production?\nI'm managing a data warehouse with intricate SQL queries that pull from multiple joined tables, often involving subqueries and aggregations for reports on user behavior and sales metrics. These can get messy, like a query that calculates monthly churn rates by segmenting customers based on activity logs spanning over a year, and one wrong condition could skew the entire dataset or even crash the prod environment due to resource overload.\n\nTo avoid disasters, I always test in a staging setup first, running the query against a subset of data—say, the last three months—to check execution time and output accuracy. I compare results side by side with expected values from smaller manual calculations, and use EXPLAIN PLAN to spot any full table scans that might not scale well.\n\nFor deeper analysis, I rely on dbForge Edge to simulate the query in a safe sandbox, where it highlights potential issues like index misses or inefficient joins before anything touches live data. It also lets me diff schemas between dev and prod to catch mismatches early.\n\nWhat processes do you follow in your workflows to catch bugs in heavy queries? Do you automate any of this with scripts or CI/CD pipelines?", "subreddit": "r/SQL", "upvotes": 11, "date": "[PHONE]", "source": "https://www.reddit.com/r/SQL/comments/1qv3n8c/how_do_you_validate_complex_queries_before/"}
{"prompt": "Data prep vs. writing queries?", "completion": "Data prep vs. writing queries?\nWhen you're building a new database project, do you find yourself spending more time cleaning and preparing the data, or writing the actual complex queries? 🛠️", "subreddit": "r/SQL", "upvotes": 11, "date": "[PHONE]", "source": "https://www.reddit.com/r/SQL/comments/1trbx81/data_prep_vs_writing_queries/"}
{"prompt": "How far did you go with SQLITE", "completion": "How far did you go with SQLITE\nI would like some feedback about how far did you go with sqlite, like what you built -> how it went -> how do you optimize so I can have a better overview so what can be done (when It done properly) with sqlite", "subreddit": "r/SQL", "upvotes": 11, "date": "[PHONE]", "source": "https://www.reddit.com/r/SQL/comments/1t787ah/how_far_did_you_go_with_sqlite/"}
{"prompt": "Starting a class focused on SQL Server & SSIS pipelines - any recommended resources?", "completion": "Starting a class focused on SQL Server & SSIS pipelines - any recommended resources?\nHi guys!\n\nI’m about to start a Business Intelligence class at uni where we’ll be going deep into the SQL. Specifically, we'll be learning:\n\n1. **SQL Server** for Data Warehousing.\n2. **Visual Studio SSIS** (ETL) to design and implement data pipelines.\n3. **Power BI** for the final presentation and visualization layer.\n\nI want to make sure I have a solid foundation before the class picks up speed. I'm looking for recommendations on books, documentations, videos that are particularly helpful for\n\n1. **SQL Server / T-SQL**\n2. **SSIS / ETL:** are there any \"go-to\" guides for a beginner to understand the logic of moving data from A to B?\n3. **Data Warehousing Theory:** any must-read books to understand\n\nThanks in advance!", "subreddit": "r/SQL", "upvotes": 10, "date": "[PHONE]", "source": "https://www.reddit.com/r/SQL/comments/1qiikz2/starting_a_class_focused_on_sql_server_ssis/"}
{"prompt": "How do you handle running SQL scripts across many servers/databases?", "completion": "How do you handle running SQL scripts across many servers/databases?\nI’m curious how others deal with this workflow.\nIn my job we have many SQL Server instances with multiple environments (dev/test/prod copies). Almost every day we need to update database structures or run batches of scripts across dozens of databases on several servers.\n\nDoing it manually in SSMS was slow and error‑prone, so a few years ago I built an internal tool to speed things up. It lets us load servers, fetch databases, select targets, run scripts in sequence or in parallel, see per‑database success/failure, timeline, dry‑run, etc.\n\nI’m not linking anything here — I’m more interested in the *concept* than promoting a tool.\n\nMy questions to you:\n\n* How do you handle multi‑server / multi‑database updates?\n* Do you use custom tools, SSMS, scripts, CI/CD, something else?\n* Would features like parallel execution, dry‑run, or execution timeline be useful in your workflow?\n* What would be a “must have” vs “nice to have”?\n\nI’d like to understand how others approach this problem and what matters most in real‑world scenarios.", "subreddit": "r/SQL", "upvotes": 10, "date": "[PHONE]", "source": "https://www.reddit.com/r/SQL/comments/1stef67/how_do_you_handle_running_sql_scripts_across_many/"}
{"prompt": "Frontend polling + heavy SQL joins = deadlocks. Looking for architecture advice", "completion": "Frontend polling + heavy SQL joins = deadlocks. Looking for architecture advice\nHi everyone,\n\nI’d like some advice on a scalability/database architecture issue.\n\nAt work, we built a truck management system. Trucks enter the factory, load products, and deliver them to different distribution centers.\n\nThe problem is that management now wants near real-time dashboards showing the full lifecycle of operations. Most of our dashboard queries rely on joins against large historical tables, and some queries take 10–15 seconds to complete.\n\nRight now, the frontend polls the API on a timer to refresh dashboards. This is starting to cause issues:\n\n* Heavy read queries sometimes block write operations\n* Backend update processes occasionally deadlock with dashboard queries\n* Overall DB performance is degrading as data grows\n\nMy current idea is to create separate denormalized/reporting tables specifically for dashboards, populated every few minutes by background jobs, so dashboards stop querying historical transactional data directly.\n\nWould this be the right approach?\nHow would you handle this architecture-wise?\n\nWe're using SQL SERVER.", "subreddit": "r/SQL", "upvotes": 10, "date": "[PHONE]", "source": "https://www.reddit.com/r/SQL/comments/1thp1gj/frontend_polling_heavy_sql_joins_deadlocks/"}
{"prompt": "Question for DBAs: How much do you actually use Extended Events (.xel) vs. standard DMVs for emergency troubleshooting?", "completion": "Question for DBAs: How much do you actually use Extended Events (.xel) vs. standard DMVs for emergency troubleshooting?\n*Hey everyone, senior dev here working heavily with SQL Server performance tuning lately. Every time a server hits a massive wave of deadlocks or unexpected latency drops, the standard advice is 'spin up an Extended Event session and read the system health .xel file.'*\n\n*Am I the only one who finds opening, filtering, and digging through those logs in SSMS incredibly clunky during a crisis? Do you guys actually sit there shredding the XML nodes manually, or do you rely on third-party tools/scripts to give you plain answers?*", "subreddit": "r/SQL", "upvotes": 10, "date": "[PHONE]", "source": "https://www.reddit.com/r/SQL/comments/1vvlc53/question_for_dbas_how_much_do_you_actually_use/"}
{"prompt": "How do you guys usually handle Lot / Batch numbers in stock movement databases?", "completion": "How do you guys usually handle Lot / Batch numbers in stock movement databases?\nHey everyone, working on a DB schema for inventory/traceability and trying to settle on the cleanest way to handle lot numbers.\n\n**Quick breakdown of the requirement**: Every article arrival gets a lot number based on the arrival date and supplier ID (e.g. `09-09-Supp1`, not the real deal ofc but you get it). Stock gets moved around, transferred, and consumed, and we need to keep track of which lot moved where.\n\n\\---\n\nHere are the two ways I'm looking at:\n\n**1. Dedicated** `article_lots` **table (What I'm leaning toward)**\n\n* `articles` (`id`, `name`, ...)\n* `article_lots` (`id`, `article_id`,  `lot_number`, `created_at`)\n* `stock_movements` (`id`, `article_lot_id`, `qty`, `from_location_id`, `to_location_id`, ...)\n\nSeems clean since lot metadata (supplier, date) lives in one place, but every movement query has to join `article_lots` just to know what base `article_id` was moved.\n\n**2. Put** `lot_number` **directly on** `stock_movements` **/** `transfers` Just store `article_id` and `lot_number` straight on the movement records. Easy to query, but feels repetitive storing the same string across every single movement row.", "subreddit": "r/SQL", "upvotes": 10, "date": "[PHONE]", "source": "https://www.reddit.com/r/SQL/comments/1wavrje/how_do_you_guys_usually_handle_lot_batch_numbers/"}
{"prompt": "Want to get some opinion", "completion": "Want to get some opinion\nI have around 2 years experience in writing SQL Queries.\n\nI am quite comfortable in writing my own SQL queries most of the time.\n\nBut when I encounter others logic , specially when the query is large (including multiple joins, window functions,  nested queries etc), or I dont have prior knowledge of what they are trying to achieve, I find it challenging to even understand the query and what they are trying to do.\n\nIs this normal and do any of you face the same challenge?", "subreddit": "r/SQL", "upvotes": 10, "date": "[PHONE]", "source": "https://www.reddit.com/r/SQL/comments/1qs3ik1/want_to_get_some_opinion/"}
{"prompt": "Is this simple problem solvable with SQL?", "completion": "Is this simple problem solvable with SQL?\nI’ve been trying to use SQL to answer a question at my work but I keep hitting a roadblock with what I assume is a limitation of how SQL functions. This is a problem that I pretty trivially solved with Python. Here is the boiled down form:\n\nI have two columns, a RowNumber column that goes from 1 to N, and a Value column that can have values between 1 and 9. I want to add an additional column that, whenever the running total of the Values reaches a threshold (say, >= 10) then it takes whatever the running total is at that time and adds it to the new column (let’s call it Bank). Bank starts at 0.\n\nSo if we imagine the following 4 rows:\n\nRowNumber | Value\n\n1 | 8\n\n2 | 4\n\n3 | 6\n\n4 | 9\n\nMy bank would have 0 for the first record, 12 for the second record (8 + 4 >= 10), 12 for the third record, and 27 for the fourth record (6 + 9 >= 10, and add that to the original 12).\n\nIf you know is this is possible, please let me know! I’m working in Databricks if that helps.", "subreddit": "r/SQL", "upvotes": 10, "date": "[PHONE]", "source": "https://www.reddit.com/r/SQL/comments/1qqjcgk/is_this_simple_problem_solvable_with_sql/"}
{"prompt": "Finding a Microsoft SQL Expert to Help With DB", "completion": "Finding a Microsoft SQL Expert to Help With DB\nHi!\n\nWe have a SQL server that works with a CAD application. It was created long before my time, and it has never been maintained. It needs indexing and other maintenance badly. The company that we purchased this CAD application from will not offer any help, other than referring us to a friend of theirs who runs another company, and wants an absolutely insane amount of money to \"analyze and reconfigure\" our entire environment, including user workstations, domain controller, network, etc. We really only need someone who can help with the SQL server. I know this might sound odd, but we've had a hard time finding someone specifically for that. Can anyone advise how else why might find someone reliable? I hope it's okay to post this here, and I apologize if it's not.\n\nI'm not looking to get flamed. Just looking for genuine help.", "subreddit": "r/SQL", "upvotes": 10, "date": "[PHONE]", "source": "https://www.reddit.com/r/SQL/comments/1q7llpk/finding_a_microsoft_sql_expert_to_help_with_db/"}
{"prompt": "SQL site for non technical interview", "completion": "SQL site for non technical interview\nI have SQL interview for a non technical analyst role that uses Tableau. The interviewer said it will be a few sql queries and that’s pretty much all I know. It’s been a while since I used SQL, any sites that would help me prepare? I know the basics but I’m a bit nervous, any advice is appreciated!", "subreddit": "r/SQL", "upvotes": 10, "date": "[PHONE]", "source": "https://www.reddit.com/r/SQL/comments/1rfsq9x/sql_site_for_non_technical_interview/"}
{"prompt": "Help beginning with DBs", "completion": "Help beginning with DBs\nHi, I've recently wanted to pick up DBs as I see that it is a well paid skill (and nice to have tbh, seems useful on projects in general). I pick a Zero to Hero course on Udemy for PostGreSQL, I learned a bit of MySQL in uni a couple years ago, and that brings me to my point:\n\n1-What's the difference between MySQL, PostGreSQL, SQLite, etc.?Does it really matter that much? Is it a project focus kinda choice or just like whatever feels better? Or is it like Java vs Python vs C++ in terms of syntax/speed?\n\n2- A recommendation on an IDE/GUI that isn't DBeaver. I heard that it is the top recommendation, and while I think I understand why, Ui/Ux is super important for me when learning something, and tbh, DBeaver seems kinda old and with a ton of visual noise.\nI also tried MySQLWorkbench on uni and hated every second of it. DataGrip was kinda cool, but I didn't grasp much and used it for a quick thing some years back, so couldn't really say much on that one.\nI liked TablePlus looks, but the pay-wall to actually take advantage of it throws me off. pgAdmin is kinda weird, didn't fully understood it.\n\nAnyways, maybe I'm giving it too much thought, but I'd rather ask around here instead of asking Claude or ChatGPT about it and get abstract answers, rather have real opinions on the matter. Thanks anyway :D", "subreddit": "r/SQL", "upvotes": 10, "date": "[PHONE]", "source": "https://www.reddit.com/r/SQL/comments/1relp16/help_beginning_with_dbs/"}
{"prompt": "Is PL/SQL still in demand despite modern technologies if I already know SQL?", "completion": "Is PL/SQL still in demand despite modern technologies if I already know SQL?\nHi everyone,\n\nI already have a good understanding of SQL and I’m currently considering whether I should invest time in learning PL/SQL.\n\nHowever, I see that many modern technologies like Python, cloud databases, and data engineering tools are becoming more popular.\n\nSo my question is:\nIs PL/SQL still in demand in the job market today, or is it being replaced by newer technologies?\n\nI would appreciate insights from people working in data or backend development.\n\nThanks!", "subreddit": "r/SQL", "upvotes": 10, "date": "[PHONE]", "source": "https://www.reddit.com/r/SQL/comments/1sqltyn/is_plsql_still_in_demand_despite_modern/"}
{"prompt": "How should I update tables in Databricks?", "completion": "How should I update tables in Databricks?\nI’m very unfamiliar with data engineering (I’m a junior data analyst), so any feedback would be appreciated. I have a set up in Databricks where I use python scripts to ingest multiple table data from SAP and put them in the bronze layer. These data could be changed, added, or deleted, and we always want the latest versions of the tables.\n\nWe’ve had some iterations for updating our silver tables from bronze. At first we just called CREATE OR REPLACE TABLE, so it would overwrite all the data with fresh data every time we ran.\nThen, we used MERGE INTO to make it more efficient for incremental changes.\nThen, we used row-hash comparison in Python to update all the tables.\nThe tables don’t have many rows yet, with the largest having almost 1M rows. But we are constantly ingesting more tables as the project size grows.\nNow looking back, maybe all the iterations was a waste of time since the tables aren’t big enough. We wanted to minimize sql run time to minimize cost.\nThose who are seasoned experts, what do you think?", "subreddit": "r/SQL", "upvotes": 10, "date": "[PHONE]", "source": "https://www.reddit.com/r/SQL/comments/1tjzghi/how_should_i_update_tables_in_databricks/"}
{"prompt": "Why is COMMIT slower on cloud databases? Decent paper on what's actually happening", "completion": "Why is COMMIT slower on cloud databases? Decent paper on what's actually happening\nWAL makes a commit \"durable.\" On a single machine it's fast because the write-ahead log goes straight to local disk. In the cloud that disk is ephemeral, it's gone if the instance dies, so the database has to ship every commit's log to remote storage before it can tell you \"done.\" That round trip is a big reason cloud commit latency is what it is.\n\nThis VLDB'26 paper (BtrLog) lays out the problem and one fix pretty clearly:\n\n* EBS-style remote disk: easy, but adds latency and cost to every commit.\n* Object storage (S3): dirt cheap and durable, but way too slow per-write for transactional stuff.\n* BtrLog's middle path: write each log record to a quorum of fast SSD nodes in one network hop (so one slow node can't stall your commit), then lazily roll the logs into big chunks on S3 in the background for cheap storage. This is exactly the [Neon architecture](https://neon.com/docs/introduction/architecture-overview) but engine agnostic.\n\nThe numbers, as commit latency:\n\n* \\~70 µs per append vs 260–500 µs for EBS. So 4–5x faster, and about 3x the transaction throughput.\n\nThis compute/storage split iis how modern serverless Postgres already works. Neon does this exact pattern (its \"safekeepers\" are the quorum WAL layer), which is why you can spin up a Postgres that scales to zero and still commit fast. The paper basically asks what if that durable-log layer were a reusable building block instead of buried inside one engine.", "subreddit": "r/SQL", "upvotes": 10, "date": "[PHONE]", "source": "https://www.reddit.com/r/SQL/comments/1uimv4w/why_is_commit_slower_on_cloud_databases_decent/"}
{"prompt": "How to ORDER BY this data", "completion": "How to ORDER BY this data\ni want to sort the data by tablename, cycle. but, i want any ods\\_TABLEX to sort underneath the TABLEX tables. I have tried \"case when tablename like 'ods\\_%' then substring(tablename, 5,999) else tablename end\". But end up with TAble1, ods\\_table1, table1, ods\\_table1. Want table1, table1, ods\\_table1, ods\\_table1.\n\n    tablename   cycle\n    =================\n    ods_table1   1\n    table2       2\n    table2       1\n    table1       2\n    ods_table1   2\n    table1       1\n\n    desired results\n    ===============\n    table1       1\n    table1       2\n    ods_table1   1\n    ods_table1   2\n    table2       1\n    table2       2", "subreddit": "r/SQL", "upvotes": 10, "date": "[PHONE]", "source": "https://www.reddit.com/r/SQL/comments/1r9vo96/how_to_order_by_this_data/"}
{"prompt": "Nested Stored Procedure Solution", "completion": "Nested Stored Procedure Solution\nI am attempting to set up a stored procedure that can be called in SSRS or with a short prebuilt query that loads the proc results to a temp table and can be worked from there, but a stored procedure is being called as part of the procedure I am trying to run and it's giving a \"An INSERT EXEC statement cannot be nested\" error. I don't know of a good way to solve for this other than taking the inner proc code and just pasting it wholesale to the outer proc code, so I'm hoping for some ideas on how to get around this.\n\nThe concept is to build a data set with a dynamic \"As of\" date the user can select. This is for claims data which is important because I am doing this at both a \"Header\" level (John Smith saw Dr Bill on 3/25/26 and the claim paid $100) and at a \"Line\" level (John Smith saw Dr Bill on 3/25/26 for a standard office visit that paid $80 and a flu shot for $20).\n\nSo my inner proc is compiling all of the claims data at a \"Header\" level as of whatever date the user selects and storing the results in a temp table I can refer back to. I need this in my outer proc code because the way our vendor has things setup is a nightmare. They don't have great set logic for making line level calculations so I was able to back into their results by doing a series of attempts to calculate \"Line\" level amounts, sum those up to a \"Header\" level, and then compare that result with my \"Header\" level results. The ones that match I hold as good, the ones that don't I keep trying different combinations of charge and adjustment codes until they do tie out to the \"Header\" level. After about 6 passes it all sorts out and matches.\n\nSo I need the header level proc to have the same \"As of\" date as the line and I need them both to be built on demand, but again I'm hitting a road block because I can't pass the results of one proc to the next.\n\nOpen to any ideas that may get around the nested proc issue while maintaining the dynamic build based on user selection.", "subreddit": "r/SQL", "upvotes": 10, "date": "[PHONE]", "source": "https://www.reddit.com/r/SQL/comments/1s3g9pg/nested_stored_procedure_solution/"}
{"prompt": "One stop free solution for SQL interview preparation", "completion": "One stop free solution for SQL interview preparation\nOkay let's stop this once and for all. How many guys need a proper SQL based interview preparation source that covers all sql concepts like from SELECT to getting information schema. I'm talking  about the jobs where SQL is really really mandatory.", "subreddit": "r/SQL", "upvotes": 10, "date": "[PHONE]", "source": "https://www.reddit.com/r/SQL/comments/1royqm1/one_stop_free_solution_for_sql_interview/"}
{"prompt": "SQL developer Project ideas", "completion": "SQL developer Project ideas\nHi, so I want some ideas for SQL Developer. There is a job posting for SQL Developer Trainee and here is the description of job listing:\nJob Summary\nWe are looking for a motivated SQL Developer Trainee to join our dynamic IT team. In this role, you will work under the guidance of experienced database professionals to learn and apply SQL development best practices, support database management, and contribute to data-driven solutions for our business needs.\n\nKey Responsibilities:\nLearning & Development:\nGain hands-on experience with relational database management systems (e.g., MS SQL Server, MySQL, Oracle).\nLearn to write, test, and optimize SQL queries for data retrieval and manipulation.\nDatabase Support:\nAssist in creating, maintaining, and troubleshooting database objects such as tables, views, stored procedures, and functions.\nSupport database administrators and developers in routine maintenance and backup operations.\nData Analysis & Reporting:\nHelp develop simple reports and dashboards using SQL and reporting tools.\nParticipate in data validation and quality checks.\nCollaboration:\n Work closely with developers, analysts, and other team members to understand business requirements.\nParticipate in team meetings and contribute to project discussions.\nDocumentation:\nAssist in documenting database schemas, processes, and best practices.\nContinuous Improvement:\nStay updated with emerging database technologies and trends.\nParticipate in training sessions and workshops to enhance technical skills.\n\n\nQualifications & Skills\n Education: Pursuing or recently completed a degree in Computer Science, Information Technology, or a related field.\nTechnical Skills:\nBasic understanding of SQL and relational database concepts.\nFamiliarity with at least one database management system (MS SQL Server, MySQL, Oracle, or similar).\nWillingness to learn new technologies and tools.\nSoft Skills:\n\nStrong analytical and problem-solving abilities.\nGood communication and teamwork skills.\nEagerness to learn and adapt in a fast-paced IT environment.\nAttention to detail and commitment to data accuracy.\n Experience: 0-1 years\n\nSo I want to make one or two projects which can make my chance of getting this job high.", "subreddit": "r/SQL", "upvotes": 10, "date": "[PHONE]", "source": "https://www.reddit.com/r/SQL/comments/1t1lk4x/sql_developer_project_ideas/"}
{"prompt": "Database-Specific SQL Differences", "completion": "Database-Specific SQL Differences\nHave you ever written a SQL query that works perfectly in one database but fails in another?\n\nWhat SQL feature or syntax surprised you the most when switching between DBMSs like MySQL, PostgreSQL, SQL Server, Oracle, or Snowflake?", "subreddit": "r/SQL", "upvotes": 10, "date": "[PHONE]", "source": "https://www.reddit.com/r/SQL/comments/1w78ess/databasespecific_sql_differences/"}
{"prompt": "SELECT hardcoded row plus ordered subquery", "completion": "SELECT hardcoded row plus ordered subquery\nI'm trying to get a stored procedure to return a data set with a single hardcoded row on top, and a sorted set of records under that first row.  I didn't realize at the time that you can't use an ORDER BY in a subquery, so my resulting set of records isn't in the correct order.\n\nEDIT, I have it working but not sure if there is an easier way.\n\n`CREATE PROCEDURE [dbo].[spReport_GetNav]`\n`AS`\n`BEGIN`\n\t`SET NOCOUNT ON;`\n\t`-- Set up Temp Table and hardcode first record`\n\t`CREATE TABLE #ReportNav (`\n\t\t`[RptName] VARCHAR(200),`\n\t\t`[ReportId] INT,`\n\t\t`[IsPartial] BIT,`\n\t\t`[EndDate] DATE )`\n\t`INSERT INTO #ReportNav ([RptName], [ReportId], [IsPartial], [EndDate])`\n\t\t`VALUES ('Import New Report Data', -1, 0, NULL);`\n\t`-- Set up field variables and cursor`\n\t`DECLARE @ RptName VARCHAR(200), @ ReportId INT, @ IsPartial BIT, @ EndDate`  `DATE;`\n\t`DECLARE csrReports CURSOR FOR`\n\t`SELECT [RptName], [ReportId], [IsPartial], [EndDate]`\n\t`FROM [dbo].[Report] ORDER BY [EndDate] DESC;`\n\n\t`OPEN csrReports`\n\t`FETCH NEXT FROM csrReports INTO @ RptName, @ ReportId, @ IsPartial, @ EndDate;`\n\t`WHILE @@FETCH_STATUS = 0`\n\t`BEGIN`\n\t\t`INSERT INTO #ReportNav ([RptName], [ReportId], [IsPartial], [EndDate])`\n\t\t\t`VALUES (@ RptName, ReportId, IsPartial, EndDate);`\n\t\t`FETCH NEXT FROM csrReports INTO RptName, ReportId, IsPartial,EndDate`\n\t`END`\n\t`CLOSE csrReports;`\n\t`DEALLOCATE csrReports;`\n\t`SELECT * FROM #ReportNav`\n\t`DROP TABLE #ReportNav`\n`END`\n\nIs there a way to get my mostly ordered set of records, with my single hardcoded row at the top of my result set, without having to use a cursor?", "subreddit": "r/SQL", "upvotes": 10, "date": "[PHONE]", "source": "https://www.reddit.com/r/SQL/comments/1q2frwd/select_hardcoded_row_plus_ordered_subquery/"}
{"prompt": "Query a local spreadsheet?", "completion": "Query a local spreadsheet?\nHey y’all, I’m in kind of a strange situation here. I’m working for a “zombie company” where I have no system accesses and no tech support. I’m trying to report on some data collected from a 3rd party app my company uses, and of course, they won’t pay for integration.\n\nSo I’m wondering if there’s any way I can pull data from the app, drop it in a spreadsheet on a network drive, and pull that data into a SQL query (for use in an SSRS report)? Has anyone ever done anything like that? I’ve googled and asked Claude, and everyone says to set up a new report server, which, of course, I don’t have access to do. Anyone know of any other solution? TIA!", "subreddit": "r/SQL", "upvotes": 10, "date": "[PHONE]", "source": "https://www.reddit.com/r/SQL/comments/1qtjv7s/query_a_local_spreadsheet/"}
{"prompt": "Can a LEFT JOIN ever return less number of rows than the base table with no where conditions?", "completion": "Can a LEFT JOIN ever return less number of rows than the base table with no where conditions?\nI am using snowflake sql. I have a weird situation where some query is returning less number of rows than the base table. The query structure is something like this:\n\nwith cte1(...),\ncte2(...)\nSELECT\n...\nFROM base\\_table t1\nLEFT JOIN left\\_table1 lt1 ON [t1.id](http://t1.id) = lt1.t1\\_id\nLEFT JOIN left\\_table2 lt2 ON [lt1.id](http://lt1.id) = lt2.lt1\\_id\nLEFT JOIN cte2 ON t1.token\\_id IN (SELECT token\\_id FROM cte1)\n\nnow the above query returns like 20K rows while doing\n\nSELECT COUNT(\\*) FROM base\\_table t1\n\nreturns like 300K rows. Is this ever supposed to happen or am I missing something? I also talked this with my team and it was a bit strange for everyone. So I am curious.", "subreddit": "r/SQL", "upvotes": 10, "date": "[PHONE]", "source": "https://www.reddit.com/r/SQL/comments/1rrtmv6/can_a_left_join_ever_return_less_number_of_rows/"}
{"prompt": "What mobile app do you use the most for SQL monitoring?", "completion": "What mobile app do you use the most for SQL monitoring?\nHi, currently I’m out of my home country and would like to know what are the best Android apps to monitor and remote connect to SQL databases, as I don’t have access currently to a PC.", "subreddit": "r/SQL", "upvotes": 10, "date": "[PHONE]", "source": "https://www.reddit.com/r/SQL/comments/1sdesvz/what_mobile_app_do_you_use_the_most_for_sql/"}
{"prompt": "SQL unit tests implementation", "completion": "SQL unit tests implementation\nHey all!\n\nI have reached a point where I am spending more time qa-ing my code than writing code and was looking at a way to make it more efficient and came across unit testing in software development.\n\nMy sql scripts sit at about 1.5k to 2k lines of code but the core of the script is usually 15-20 case when statements that contain the business logic.  I wanted to ask the community if it is possible to build something that contains source data and expected outputs and compare the output of the script against those expected outputs for these test scenarios.\n\nIf so, how do you execute it?  Do you keep the test data in the same script, do you create SPs for testing, how do you make the distinction between real data and test data?  Are there any pitfalls I should be aware of?  Are there any tools that will make this easier for me?", "subreddit": "r/SQL", "upvotes": 10, "date": "[PHONE]", "source": "https://www.reddit.com/r/SQL/comments/1tu04hx/sql_unit_tests_implementation/"}
{"prompt": "How Do I Combine Hex Values in SQL?", "completion": "How Do I Combine Hex Values in SQL?\nSo I am working on a database schema that isn't mine in MySQL. The database has tuples that include hex values in it, for example:\n\n`Key1 = 0x000000000000000080000000`\n`Key2 = 0x000000000000000000000020`\n`Key3 = 0x000000000000000000000002`\n\nThere are something like 40 keys and they each interact with each other in different ways, so to track how they should interact, the intent of these hexes is to act as a bitmask. We are trying to future proof this a decent amount so  So with that in mind, I am trying to figure out how to combine the above hexes to look something like:\n\n\n`0x000000000000000080000022`\n\nI am very dense when it comes to using hex, but I am working with what's been handed to me. I tried to use \\`SUM()\\` on the hex values, but it didn't like that at all. I attempted to use a \\`CAST()\\` inside of the SUM, but that didn't help either and I think I just goofed it all up.\n\nThe hexmask data type is BINARY(12).\n\nMy MySQL version is:\n\n`mysql  Ver 8.0.41-0ubuntu[IP] for Linux on x86_64 ((Ubuntu))`\n\nThank you in advance!", "subreddit": "r/SQL", "upvotes": 9, "date": "[PHONE]", "source": "https://www.reddit.com/r/SQL/comments/1qd27u4/how_do_i_combine_hex_values_in_sql/"}
{"prompt": "A quick question for SQL veterans about memorization and debugging", "completion": "A quick question for SQL veterans about memorization and debugging\nHey everyone! I’m working on a data analyst project right now and wanted to get some insight from the pros regarding industry-standard workflows. 🛠️\n\nInstead of a generic learning question, I have two specific questions about how experienced data professionals operate daily:\n\n**1. Function Memorization vs. Documentation lookup 📚**\nHow do you veterans balance memorizing syntax versus using external references? Coming from Excel, the built-in Intellisense hints made writing formulas easy. SQL feels like it requires a massive amount of mental overhead. Do you actually memorize every single window function and string manipulation method, or is heavy reliance on documentation and Google completely normal in a production environment?\n\n**2. AI Code Review for Syntax Troubleshooting 🤖❌**\nI find myself losing time to minor syntax errors, like misplaced commas or incorrect logical sequencing in complex `GROUP BY` and `HAVING` clauses. Is it considered acceptable by industry standards to use AI as a quick debugging partner to spot these syntax errors, or should I be focusing on a different method to build code accuracy?\n\nAppreciate any insights on how you optimize your daily coding workflow! 🚀", "subreddit": "r/SQL", "upvotes": 9, "date": "[PHONE]", "source": "https://www.reddit.com/r/SQL/comments/1uoyhgc/a_quick_question_for_sql_veterans_about/"}
{"prompt": "Can SQL Anywhere run on Windows 11?", "completion": "Can SQL Anywhere run on Windows 11?\nCan SQL Anywhere run on Windows 11? I have a customer who has this database running his accounting and customer service appointments. I still have to find out what version it is. The offices has 3 windows 7 at the front counter running the software and server is in the data closet.", "subreddit": "r/SQL", "upvotes": 9, "date": "[PHONE]", "source": "https://www.reddit.com/r/SQL/comments/1un5nbh/can_sql_anywhere_run_on_windows_11/"}
{"prompt": "anyone using SQL to track espresso shot data?", "completion": "anyone using SQL to track espresso shot data?\nbeen logging my dialin sessions in a spreadsheet but it feels messy once you start tracking multiple beans and grinder settings. a friend suggested throwing it into a small postgres db so I can query things like \"which beans respond best to a 15g dose at 200f\" without scrolling forever. not sure if that's overkill or if other people do this with their brew notes. the main things I'd want to pull out quickly are shot time, yield, and perceived taste notes tied to roast date and water temp. any reason this would be a bad idea for something this small scale?", "subreddit": "r/SQL", "upvotes": 9, "date": "[PHONE]", "source": "https://www.reddit.com/r/SQL/comments/1wqy0v4/anyone_using_sql_to_track_espresso_shot_data/"}
{"prompt": "Schema3D update: Now open-source with shareable schema URLs", "completion": "Schema3D update: Now open-source with shareable schema URLs\nPosted here a few months back about [Schema3D](https://schema3d.com/) \\- a 3D schema visualizer. Based on your feedback, I've added several high-impact features (and the entire project is now open-sourced).\n\n**What's changed:**\n\n* Editable category filtering: tag tables and filter by domain/service/feature\n* Shareable URLs - no database, entire schema in the URL\n* Open source on GitHub - full code available\n\n**Links**:\n\n* [Demo](https://schema3d.com/)\n* [GitHub](https://github.com/shane-jacobeen/schema3d)\n* [Previous post](https://www.reddit.com/r/SQL/comments/1pi97uh/schema3d_an_experiment_to_solve_the_erd_spaghetti/)\n\nThe URL sharing was technically interesting - had to implement compression since schemas can get large, and the link contains the view state as well as the schema definition.\n\nWould love to know: Do you see yourself using something like this for documentation or onboarding?", "subreddit": "r/SQL", "upvotes": 9, "date": "[PHONE]", "source": "https://www.reddit.com/r/SQL/comments/1qodics/schema3d_update_now_opensource_with_shareable/"}
{"prompt": "Strange join behaviour in MS SQL Server", "completion": "Strange join behaviour in MS SQL Server\nHello everybody, I just can't figure out what's going on with a query I'm working on.\n\nI'm using SQL Server Management Studio to develop and test a query with a rather simple join. Joined tables (note: X is a view, Y is a table) are in different DBs but on the same Server. The user has the same grants on both DBs.\n\nThe code is basically like this:\n\n    SELECT X.a,\n        X.b,\n        Y.c,\n        Y.d\n    FROM [DB1].[dbo].[X]\n        left outer join [DB2].[dbo].[Y]\n        on X.e = Y.e\n        and X.f = Y.f\n\nAs you know, in SQL Management Studio you can select the database where to run the query.\n\nIf I select to run it in DB1, the query runs forever with no results and I have to stop it manually. If I run it in DB2 the query ends correctly in about 10 seconds. I tried also to invert the join but the result is the same.\n\nAnother strange thing is that if I comment just the rows where I select Y.c and Y.d (but I leave the rest as it is, join included), the query runs fine also on DB1. So the problem doesn't seem to be on the join itself, but related to the attributes I'm using in the result.\n\nI've never seen this behaviour in many years working on SQL Server... Do you have any idea?\n\nThanks in advance", "subreddit": "r/SQL", "upvotes": 9, "date": "[PHONE]", "source": "https://www.reddit.com/r/SQL/comments/1qoax8x/strange_join_behaviour_in_ms_sql_server/"}
{"prompt": "Do you guys actually trust the data flowing into your warehouse?", "completion": "Do you guys actually trust the data flowing into your warehouse?\nI've seen cases where the pipelines were technically \"working\" but the data itself was slightly off (missing chunks, delayed ingestion, weird values) and no one noticed until dashboards started acting odd.\n\nI am curious about how this will play out in real setups.\n\nDo you take incoming data at face value or have you had instances where something looked ok but was not?\n\nAnd when that happens… Is it a little thing, or does it really take time to find out?", "subreddit": "r/SQL", "upvotes": 9, "date": "[PHONE]", "source": "https://www.reddit.com/r/SQL/comments/1su6hjd/do_you_guys_actually_trust_the_data_flowing_into/"}
{"prompt": "I'm learning and have a more advanced question", "completion": "I'm learning and have a more advanced question\nHi all,\n\nI am , i'd say moderate user of SQL, typically for more advanced or complicated aggregations , i tend to export a bunch of raw data into a spreedsheet and pivot table and the like from there, but as an exercise in improving my sql skills, i've given myself a challenge.\n\nI have a pretty simple table that for the purposes of this question boils down to a date and quantity dimension.\n\nThe simple way to do achieve my goal would be group the quanitites by month. This is easily achieved by extracting month from date field, and grouping by month to sum quantity.\n\nHowever, in the same query, what I have challenged myself to do is to sum up all months but the current one, where the daily details might still matter. So for any older month, I should have 1 row with the total, and for this current month, it would still show every individual record.  (Maybe I just end up with past 7 days instead of current month, but I cant tweak that later).\n\nIm new to window functions, and this what i'm challenging myself with, and how i think would be the rigth way to do it....   But I'm stuck on having different (or no) aggregation for current month.  What I'm thinking is that I could use a window function to partition over MONTH, that would give me every row  back with a total per month, and then I could select MAX from each month, to trim it down to one row.\n\nBut how do I avoid doing any aggregations to current month then?\n\nThanks for any tips.... Im really hoping to learn from this, so discussion is preferred vs, just an answer.  Cheers!", "subreddit": "r/SQL", "upvotes": 9, "date": "[PHONE]", "source": "https://www.reddit.com/r/SQL/comments/1shppe1/im_learning_and_have_a_more_advanced_question/"}
{"prompt": "Tricky interview question about .ldf size on MS SQL Server", "completion": "Tricky interview question about .ldf   size on MS SQL Server\nHi, I was applying for SQL dev position and got this question:\nQ:  you need to import 500G .csv file into MS SQL Server table. What approach you would use to avoid problems with log file size restrictions.\n\n\nDidn't have experience with this case. I think if you create on the fly package with Right click import, everything will be taken care of. Am I right ?  or I can somehow control /shrink .ldf file  or break .csv into several pieces.?\n\nThanks all\nVA", "subreddit": "r/SQL", "upvotes": 9, "date": "[PHONE]", "source": "https://www.reddit.com/r/SQL/comments/1ujeq61/tricky_interview_question_about_ldf_size_on_ms/"}
{"prompt": "What SQL client has the best formatter if you’re picky about SQL style?", "completion": "What SQL client has the best formatter if you’re picky about SQL style?\nI’ve found that most formatters are configurable up to a point, but eventually you’re still forced into their idea of what “well formatted SQL” looks like.\n\nDo you know any client where you can really personalize how SELECTs, INSERTs, UPDATEs and DELETEs are formatted?\n\nOr do you also miss having a formatter that actually adapts to your preferred SQL style rather than the other way around?", "subreddit": "r/SQL", "upvotes": 9, "date": "[PHONE]", "source": "https://www.reddit.com/r/SQL/comments/1vrztwn/what_sql_client_has_the_best_formatter_if_youre/"}
{"prompt": "SQL Question: Rows into Columns without TABLEFUNC() or PIVOT?", "completion": "SQL Question: Rows into Columns without TABLEFUNC() or PIVOT?\nHelp me Reddit! I feel **especially** stupid today....\nSo, I have this table in my Postgresql Database:\n\n`event_id | color_scheme | count`\n`----------+--------------+-------`\n`1 | red | 6`\n`1 | green | 3`\n`1 | blue | 5`\n`1 | yellow | 3`\n`3 | red | 5`\n`4 | red | 3`\n`5 | red | 1`\n`5 | blue | 2`\n\nAnd I would like to turn it sideways, so that I can see EASILY how many votes each color scheme for my event has gotten (and later JOIN it with another table... )\n\n`event_id | count_red | count_green | count_blue | count_yellow`\n`----------+-----------+-------------+------------+--------------`\n`1 | 6 | 3 | 5 | 3`\n`3 | 5 | 0 | 0 | 0`\n`4 | 3 | 0 | 0 | 0`\n`5 | 1 | 0 | 2 | 0`\n\nThe colors \"red\" \"green\" \"blue\" and \"yellow\" are fixed, and will never ever change.\nI have done some googling, I found examples mentioning PIVOT and TABLEFUNC, but I cannot do this on the server because of reasons(tm).\n\nThe only way I can think of doing this is with a cascade of OUTER JOIN, but is there maybe a simpler solution?", "subreddit": "r/SQL", "upvotes": 9, "date": "[PHONE]", "source": "https://www.reddit.com/r/SQL/comments/1vcgsx2/sql_question_rows_into_columns_without_tablefunc/"}
{"prompt": "How would you go about documenting complex SQL queries?", "completion": "How would you go about documenting complex SQL queries?\nI'm currently in a position where they've asked me to work with SMEs and Operations to document their bespoke application. It uses a lot of SQL.\n\nI know writing SQL Comments is a good start, but what else should I take note of? I'm already documenting Business logic, and the reason behind certain query decisions.​", "subreddit": "r/SQL", "upvotes": 9, "date": "[PHONE]", "source": "https://www.reddit.com/r/SQL/comments/1qeluku/how_would_you_go_about_documenting_complex_sql/"}
{"prompt": "is sql still the main interface for exploring data?", "completion": "is sql still the main interface for exploring data?\na lot of analysis still seems to start with writing queries. dashboards track metrics, but when a new question comes up it usually means opening a sql editor and digging through tables.\n\nrecently saw a founder on linkedin building something called genloop that lets you ask questions about data in plain language and generates the query behind the scenes. tools like hex or mode already help with exploration, but this feels closer to replacing part of the manual sql workflow.\n\ncurious how people see this evolving. does sql stay the main interface for analysis, or do these tools actually change how people explore data?", "subreddit": "r/SQL", "upvotes": 9, "date": "[PHONE]", "source": "https://www.reddit.com/r/SQL/comments/1rnd6kb/is_sql_still_the_main_interface_for_exploring_data/"}
{"prompt": "4 months after layoff and feeling lost — 4 yrs experience, trying to switch to SQL roles", "completion": "4 months after layoff and feeling lost — 4 yrs experience, trying to switch to SQL roles\nI was laid off in Dec 2025 after working 4 years in an MNC (operations/support role). Since then, I’ve been trying to figure out my next move, but honestly I feel stuck.\n\nI have basic SQL knowledge, but no strong coding background. Most of my experience is in customer support and operations.\n\nI’m trying to shift into SQL support or reporting/analyst roles, but I don’t know if I’m doing the right things or wasting time.\n\nRight now I’m focusing on SQL and thinking of learning Power BI, but I’m not confident if that’s enough to get hired.\n\nIf anyone has been in a similar situation or works in these roles, I’d really appreciate your guidance:\n\n\\- What should I focus on?\n\n\\- How do I become job-ready quickly?\n\n\\- Am I already too late?\n\nAny honest advice would really help. Thanks.", "subreddit": "r/SQL", "upvotes": 9, "date": "[PHONE]", "source": "https://www.reddit.com/r/SQL/comments/1s5vlut/4_months_after_layoff_and_feeling_lost_4_yrs/"}
{"prompt": "SQL Cookbook 3.9 (3rd edition)", "completion": "SQL Cookbook 3.9 (3rd edition)\nI just started reading the SQL cookbook. In problem 3.9 (Performing Joins When Using Aggregates) the first solution presented uses `sum(distinct sal)` instead of `sum(sal)` in the main (outermost) query. The purpose is to avoid including the salary for 'Miller' twice in the sum.\n\nAlthough this works for the specific example given in the book, it seems wrong to me because it seems to assume that no other employee has the same salary. If some other employee has the same salary as 'Miller', wouldn't this return an incorrect sum? What am I missing?\n\nThe other presented solution uses sum() as a window function twice. I have no comment to make about it, other than I came up with a similar solution myself that seems to work, which I will put here. Kindly rip it to shreds if I screwed something up:\n\n    select distinct e.empno, e.ename, e.sal, e.deptno, round(e.sal * eb.bonus,2)\n    from emp e inner join\n       (select empno, sum(case\n                            when type=1 then 0.1\n                            when type=2 then 0.2\n                            when type=3 then 0.3\n                            else 0\n                          end)\n                      over(partition by empno) as bonus from emp_bonus) eb\n    on e.empno = eb.empno\n    where e.deptno='10';", "subreddit": "r/SQL", "upvotes": 9, "date": "[PHONE]", "source": "https://www.reddit.com/r/SQL/comments/1rr17cc/sql_cookbook_39_3rd_edition/"}
{"prompt": "I built an open SQL Server \"clone\" in Rust (Iridium SQL", "completion": "I built an open SQL Server \"clone\" in Rust (Iridium SQL\nI’ve been working on **Iridium SQL**, an open database engine written in Rust.\n\nThe goal is to build a **SQL Server-compatible** engine and server that works well for application-facing use cases, while also supporting different runtime shapes. Right now the project includes:\n\n* a T-SQL engine with a native TDS server\n* persistent storage by default in native/server mode\n* WASM support for embedding and browser/local use\n* a TypeScript client and browser playground\n\nOne thing I’m trying to be careful about is **compatibility claims**: the target is SQL Server compatibility, but I’m not pretending it has full parity. I’m tracking behavior and compatibility explicitly instead of hand-waving it.\n\nRepo: [`https://github.com/celsowm/iridium-sql`](https://github.com/celsowm/iridium-sql)\n\nCrates: [`https://crates.io/crates/iridium_server`](https://crates.io/crates/iridium_server)\n\nI’d really love feedback from Rust folks on the architecture, project direction, API/design choices, and anything that stands out as a good or bad idea.", "subreddit": "r/SQL", "upvotes": 9, "date": "[PHONE]", "source": "https://www.reddit.com/r/SQL/comments/1sliqim/i_built_an_open_sql_server_clone_in_rust_iridium/"}
{"prompt": "VARCHAR vs CAST AS varchar", "completion": "VARCHAR vs CAST AS varchar\nI'm converting a decimal value to a VARCHAR on a DB2 system. I'm finding one syntactical version works, and another doesn't. I'm coming up short when trying to explain to myself why.\n\n    SELECT VARCHAR(My_Field)\n    FROM My_Table\n\nworks!\n\n    SELECT CAST(My_Field AS VARCHAR)\n    FROM My_Table\n\ndoesn't work--\"Attributes not valid\" error.\n\nWeirdly:\n\n    SELECT CAST(My_Field AS CHAR)\n    FROM My_Table\n\nworks.\n\nWhat am I not understanding? Many thanks!", "subreddit": "r/SQL", "upvotes": 9, "date": "[PHONE]", "source": "https://www.reddit.com/r/SQL/comments/1te6gya/varchar_vs_cast_as_varchar/"}
{"prompt": "SQL usage for a Data Analyst with 4 years of experience", "completion": "SQL usage for a Data Analyst with 4 years of experience\nFor those with around 4 years of experience as a data analyst, how do you use SQL in your day-to-day work?\n\nRoughly how much SQL do you write each day, and how many lines are your typical queries? I'm trying to understand what real-world SQL work looks like.\n\nThanks!", "subreddit": "r/SQL", "upvotes": 9, "date": "[PHONE]", "source": "https://www.reddit.com/r/SQL/comments/1ukg8f4/sql_usage_for_a_data_analyst_with_4_years_of/"}
{"prompt": "How do I get the count of identical combinations that unique products share AND display that in the final result?", "completion": "How do I get the count of identical combinations that unique products share AND display that in the final result?\nI can roll with any flavor, I just need help getting the basic method down (this is why I didn’t bother with the behind the scenes tables)\n\nImagine you have cars, each car has a vin number which is unique. These cars each have packages. A package is a collection of parts. Each vin can have multiple packages.\n\nFor example:\n\nVin 1 has package A, package B, and Package c\n\nVin 2 has package A, package B, and Package c\n\nVin 3 has package B, Package c\n\nVin 4 has package A, package B, and Package c\n\nVin 5 has Package c\n\nVin 6 has package B, Package c\n\nFinal result should be\n\nVin……….number of vins that share package combo\n\nVin 1……..3\n\nVin 2……..3\n\nVin 3……..2\n\nVin 4……..3\n\nVin 5……..1\n\nVin 6……..2\n\nApologies for my ass formatting I am on mobile.", "subreddit": "r/SQL", "upvotes": 8, "date": "[PHONE]", "source": "https://www.reddit.com/r/SQL/comments/1qvvq8j/how_do_i_get_the_count_of_identical_combinations/"}
{"prompt": "Title: Complete beginner: Which database should I learn first for app development in 2026?", "completion": "Title: Complete beginner: Which database should I learn first for app development in 2026?\nHey everyone, I'm just starting my journey into app development and I'm feeling a bit overwhelmed by the database options (SQL, NoSQL, Firebase, Postgres, etc.).\n\nI want to learn something that is:\n\n1. **Beginner-friendly** (good documentation and tutorials).\n2. **startup point up view** (helps with making a large scale app).\n3. **Scalable** for real-world apps.\n\nIs it better to start with a traditional SQL database like **PostgreSQL**, or should I go with something like **MongoDB** or a BaaS (Backend-as-a-Service) like **Supabase/Firebase**? What’s the \"gold standard\" for a first-timer in 2026?", "subreddit": "r/SQL", "upvotes": 8, "date": "[PHONE]", "source": "https://www.reddit.com/r/SQL/comments/1rvkkxb/title_complete_beginner_which_database_should_i/"}
{"prompt": "Database Restores, how do you do it?", "completion": "Database Restores, how do you do it?\nHi All,\n\nBackground - like most businesses we have Dev, Acceptance and live environments for our developers. We are looking for a controlled way we can refresh the data in the Dev and Acceptance DBs from the current live database.\n\nHistorically, the backup solution at the time would dump a .bak file into a folder once the backup was complete. From there multiple scripts were ran to put the data back into either of the other DBs and sanitise it, ready for use by the developers.\n\nIdeally we would like to find a way to automate the process as our new backup product doesn’t provide that functionality so we are currently taking manual backups every time the devs need fresh data.\n\nDoes anyone know of any low cost or free products that would do this? How is it done in other organisations?\n\nThanks in advance.", "subreddit": "r/SQL", "upvotes": 8, "date": "[PHONE]", "source": "https://www.reddit.com/r/SQL/comments/1sr0kfk/database_restores_how_do_you_do_it/"}
{"prompt": "Please help to fix my career. DBA -> DE failed. Now DBA -> DA/BA. Need honest advice.", "completion": "Please help to fix my career. DBA -> DE failed. Now DBA -> DA/BA. Need honest advice.\nHey guys,\n\nI'm a DBA with 2.5 yoe on legacy tech (Db2 for mainframe). Initially, I tried to fix this as my career. But after 1 year, I realised that this is not for me.\n\nNight shifts. On-call. Weekends gone (mostly). Now health is taking a hit.\n\nNot a performance issue - I literally won an eminence award for my work. But this tech is draining me and I can't see a future here.\n\n**What I already tried:**\n\nGot AWS certified. Then spent 2nd year fully grinding DE — SQL, Spark, Hadoop, Hive, Airflow, AWS projects, GitHub projects. Applied to MNCs. Got \"***No longer under consideration***\" from everyone. One company gave me an OA then ghosted. 2 years gone now. I feel like its almost impossible to get into DE without prior experience in it.\n\n**Where I'm at now:**\n\nI think **DA/BA** is more realistic for me. I already have:\n\n* Advanced SQL, Python, PySpark, AWS\n* Worked on Real cost-optimization project\n* Data Warehouse + Cloud Analytics pipeline projects on GitHub\n* Stakeholder management experience (To some extent)\n\nI believe only thing missing honestly - Data Visualization - **Power BI** / Tableau, Storytelling, Business Metrics (Analytics POV).\n\n**The MBA question:**\n\nSomeone suggested **1-year PGPM** for accelerating career for young professional. But 60%+ placements go to Consulting in most B-Schools. Analytics is maybe 7% (**less than 10%**). I'm **not an extrovert** who can dominate B-School placements. Don't want to spend 25L and end up in another role I hate.\n\n**What I want:**\n\nDA / BA / BI Analyst. General shift. MNC (Not startup). Not even asking for hike. Just a humane life.\n\n**My questions:**\n\n* Anyone successfully pivoted to DA/BA from a non-analytics background? What actually worked?\n* Is Power BI genuinely the missing piece or am I missing something bigger?\n* MBA for Analytics pivot - worth it or consulting trap?\n* How do I get shortlisted when my actual role is DBA but applying for DA/BA roles?\n* Is the market really that bad, or am I just unlucky?\n\nI'm exhausted from trying. But I'm not giving up. Just need real advice from people who've actually done this.\n\nThanks 🙏", "subreddit": "r/SQL", "upvotes": 8, "date": "[PHONE]", "source": "https://www.reddit.com/r/SQL/comments/1sallf2/please_help_to_fix_my_career_dba_de_failed_now/"}
{"prompt": "SAP ECC to SQL Server: Rebuild Z-transaction logic in SQL, or extract processed data directly?", "completion": "SAP ECC to SQL Server: Rebuild Z-transaction logic in SQL, or extract processed data directly?\nI work part-time as a student on a supply chain analytics team (we use SAP ECC R/3) and my boss wants to stop using TXT/CSV batch jobs. Instead, they want to move SAP tables and Z-transaction data directly into a middle layer in SQL Server for reporting in Power BI and Excel.\n\nRight now, a colleague is copying the most important raw tables into SQL Server daily using the .NET connector. The issue is that the entire SCM department needs the Z-transactions, which have special business logic built on top of the raw SAP tables.\n\nIs it smart and viable to just copy the raw data from SAP into SQL Server and rebuild all the Z-transaction logic there, or is there a better, more efficient approach?", "subreddit": "r/SQL", "upvotes": 8, "date": "[PHONE]", "source": "https://www.reddit.com/r/SQL/comments/1todvqk/sap_ecc_to_sql_server_rebuild_ztransaction_logic/"}
{"prompt": "I made a SQL cheat sheet that covers 90% of what you'll use at work. Here's a preview.", "completion": "I made a SQL cheat sheet that covers 90% of what you'll use at work. Here's a preview.\n**Kept running into the same problem when I was learning SQL — tutorials teach you one concept at a time but you never have everything in one place when you actually need it.**\n\n**So I made a one-page reference. Here's a chunk of it:**\n\n**\\*\\*SELECT & Filter\\*\\***\n\n**SELECT column1, column2 FROM table WHERE condition;**\n\n**SELECT DISTINCT column FROM table;**\n\n**SELECT \\* FROM table WHERE column LIKE '%pattern%';**\n\n**SELECT \\* FROM table WHERE column IN ('val1', 'val2');**\n\n**SELECT \\* FROM table WHERE column BETWEEN 10 AND 50;**\n\n**\\*\\*Aggregations\\*\\***\n\n**SELECT COUNT(\\*), AVG(salary), SUM(revenue)**\n\n**FROM table**\n\n**GROUP BY department**\n\n**HAVING COUNT(\\*) > 5;**\n\n**\\*\\*JOINs\\*\\***\n\n**-- INNER: only matching rows**\n\n**SELECT \\* FROM orders o INNER JOIN customers c ON o.customer\\_id =** [**c.id**](http://c.id)**;**\n\n**-- LEFT: all from left table + matches from right**\n\n**SELECT \\* FROM customers c LEFT JOIN orders o ON** [**c.id**](http://c.id) **= o.customer\\_id;**\n\n**\\*\\*CTEs\\*\\***\n\n**WITH top\\_earners AS (**\n\n**SELECT name, salary, RANK() OVER (ORDER BY salary DESC) as rnk**\n\n**FROM employees**\n\n**)**\n\n**SELECT \\* FROM top\\_earners WHERE rnk <= 10;**\n\n**The full version also covers window functions, CASE statements, date functions, string manipulation, and indexing tips — all on one printable page.**\n\n**What else would you want on a SQL cheat sheet? Trying to make sure I'm not missing anything obvious.**\n\n**---**\n\n**Edit: Lot of people asking for the full version. DM me and I'll send you the link.**", "subreddit": "r/SQL", "upvotes": 8, "date": "[PHONE]", "source": "https://www.reddit.com/r/SQL/comments/1t0k2ap/i_made_a_sql_cheat_sheet_that_covers_90_of_what/"}
{"prompt": "Lakebase/Neon experiences from users", "completion": "Lakebase/Neon experiences from users\nLakebase was recently merged into Databricks platform after Neon’s acquisition. I have been using it lately and I like the scalability and branching features.\n\nI wanted to know experiences of other folks using it.", "subreddit": "r/SQL", "upvotes": 8, "date": "[PHONE]", "source": "https://www.reddit.com/r/SQL/comments/1tzhtiq/lakebaseneon_experiences_from_users/"}
{"prompt": "Question regarding ER diagram reification", "completion": "Question regarding ER diagram reification\nHi everyone, I have a problem: I can’t figure out whether my solution to this ER design exercise is correct. The exercise states:\n\nWe want to create a database for an online newspaper publisher.\n\nThe newspapers published by the publisher are identified by a unique code, and their name and founding year are known.\n\nThe members of the editorial board of the newspapers are identified by their email address, and their first name, last name, and a phone number (if available) are known.\n\nFor each editorial board member, we want to keep track of the roles they hold at each newspaper and the periods of time (start date and end date) during which they held each role. Note that, during the same period of time, an editorial board member may hold a role at different newspapers, but cannot hold multiple roles at the same newspaper. An editorial board member may hold the same role multiple times for the same newspaper.\n\nThe issues published for each newspaper are identified by a sequential number that is unique within the corresponding newspaper, and are characterized by their year and month of publication, as well as the name of the editorial board member who edited that issue.\n\nWithin each issue, articles are published. Each article is identified by a unique code within the corresponding issue and is characterized by its title, number of pages, and list of authors. Articles can either be freely accessible or paid. For freely accessible articles, the type of access is known (e.g., “Bronze,” “Gold,” or “Diamond”), while for paid articles, the cost of purchasing the article is known.\n\nMy main doubt concerns the reification I chose. The professor uses a ternary relationship instead. Do you think my solution is correct?", "subreddit": "r/SQL", "upvotes": 8, "date": "[PHONE]", "source": "https://www.reddit.com/r/SQL/comments/1vtjjjw/question_regarding_er_diagram_reification/"}
{"prompt": "Portabase (OSS backup/restore platform for 6 SQL DBMS) now supports rclone as storage connector", "completion": "Portabase (OSS backup/restore platform for 6 SQL DBMS) now supports rclone as storage connector\nHi everyone,\n\nWe have just released **Portabase 1.30** !\n\nRepository: [https://github.com/Portabase/portabase](https://github.com/Portabase/portabase)\n\nTo recap, Portabase is designed for data retention, disaster recovery, and homogeneous migrations. It currently supports **9 database engines** (including PostgreSQL, MySQL, MariaDB MS SQL, SQLite, Firebird SQL) and **Docker volumes**.\n\n**Key features:**\n\n* Scheduled backups with flexible retention policies (including GFS)\n* Multiple storage options: local filesystem, S3, Azure Blob Storage, GCS\n* Notifications via Discord, Telegram, Slack, AppRise, etc.\n* Support for OAuth2/OIDC (with the option to disable sign-ups)\n* Templates for ProxMox, UnraidOS, Coolify, Dokploy\n* Ready-to-use Docker Compose and Helm Chart\n\nWith this release, we’re significantly expanding storage options by adding **rclone support**, giving Portabase access to more than **70 cloud storage providers and protocols**!\n\n# What’s new in 1.30 :\n\n* rclone support\n* healthchecks.io as notification provider\n* Improved documentation for new deployment methods (Coolify, Dokploy, ProxMox)\n* Periodic checks to verify that backup files are still present in the configured storage\n* All policies (retention, storage, notifications, etc.) can now be configured at the project level and inherited by all databases within the project (while allowing database-level overrides)\n\n# Portabase is be used in professional environments\n\nThe community is growing: France, the US and Germany are currently among the most active countries around the project, and people from **163 countries** have visited the Portabase website this year.\n\nOver the past few months, professionals (companies and public-sector organizations) have started reaching out to us to get more insight into how Portabase works and how it can be adapted to their use cases. That’s particularly valuable to us because, as an open-source project, we usually have very little visibility into who is actually using Portabase and why.\n\nAs always, if you find a bug or want to suggest a feature, please open an issue on GitHub.\n\nThanks to everyone using, testing, contributing to and supporting Portabase!", "subreddit": "r/SQL", "upvotes": 8, "date": "[PHONE]", "source": "https://www.reddit.com/r/SQL/comments/1wrm2gg/portabase_oss_backuprestore_platform_for_6_sql/"}
{"prompt": "Unique identifiers", "completion": "Unique identifiers\nHas anyone had experience generating random/unique identifiers for a large number of files and could talk a bit about how they did it?\n\nI have a list of file names that are tied to personal info. My supervisor wants me to change the file names so that an Id of letters and numbers can now identify each file.\n\nThanks!", "subreddit": "r/SQL", "upvotes": 8, "date": "[PHONE]", "source": "https://www.reddit.com/r/SQL/comments/1qpdzpc/unique_identifiers/"}
{"prompt": "Are these two queries equivalent? Is one better than the other?", "completion": "Are these two queries equivalent? Is one better than the other?\nSELECT \\*\n\nFROM customer c\n\nLEFT JOIN adrP ap\n\nLEFT JOIN adrR res ON res.KEY = ap.KEY\n\n\tAND res.type IN ('PHY')\n\n\tAND res.curr = 1 ON ap.flngCustKey = c.flngCustKey\n\n\tAND ap.def = 1\n\nVs.\n\nSELECT \\*\n\nFROM customer c\n\nLEFT JOIN adrP ap ON ap.flngCustKey = c.flngCustKey\n\n\tAND ap.def = 1\n\nLEFT JOIN adrR res ON res.KEY = ap.KEY\n\n\tAND res.type IN ('PHY')\n\n\tAND res.curr = 1", "subreddit": "r/SQL", "upvotes": 8, "date": "[PHONE]", "source": "https://www.reddit.com/r/SQL/comments/1q72g8t/are_these_two_queries_equivalent_is_one_better/"}
{"prompt": "[Feedback Request] I built a native \"Daily SQL Challenge\" interactive widget for Reddit. The mods suggested I run a pilot test with you all.", "completion": "[Feedback Request] I built a native \"Daily SQL Challenge\" interactive widget for Reddit. The mods suggested I run a pilot test with you all.\nHey r/SQL,\n\nI’m a data engineer and recently built a “Daily SQL Challenge” widget that runs directly inside Reddit using Devvit.\n\nThe mods suggested running a small pilot first to see if it’s actually useful for the community.\n\nHow it works:\n\n* Shows a real SQL interview question (joins, CTEs, window functions, etc.)\n* You think/write your query\n* Click “Reveal Answer” to see solution + explanation\n* Vote on difficulty and compare with others\n\nTry it here:\n\n [https://www.reddit.com/r/sql\\_arena\\_dev/](https://www.reddit.com/r/sql_arena_dev/)\n\nNeed your feedback and if it’s helpful, I’ll push to bring this to r/SQL.\n\nThanks", "subreddit": "r/SQL", "upvotes": 8, "date": "[PHONE]", "source": "https://www.reddit.com/r/SQL/comments/1srs8m3/feedback_request_i_built_a_native_daily_sql/"}
{"prompt": "Browser-based SQLite Playground with real-time ER Diagrams (Free & Open-ish)", "completion": "Browser-based SQLite Playground with real-time ER Diagrams (Free & Open-ish)\n[ Northwind database loaded into the tool](\n\nHey everyone!\n\nA while back, I shared a project I started for my students: **SQLite Playground**. The goal was to create a tool with zero friction—no installation, no setup—just pure SQL learning.\n\nBased on feedback from my students and the dev community, I’ve just rolled out some major updates that bring it closer to a full-blown (and free) IDE running 100% in your browser.\n\n# What’s New:\n\n* **Automatic ER Diagram Visualizer:** This is the big one. The diagram generates in real-time as you create or alter tables. If you add a Foreign Key, the relationship pops up instantly.\n* **Full-Screen / Distraction-Free Mode:** A clean interface designed for deep work or classroom presentations.\n* **Import/Export (.db & .sqlite3):** You can now load existing databases or save your progress directly to your machine.\n\n[Auto generated ER Diagram](\n\nWhat started as a simple classroom tool is evolving into a lightweight online SQL IDE. I’m really trying to bridge the gap between \"beginner-friendly\" and \"feature-rich.\"\n\nI’d love to get your feedback on the **UX** or any **features** you think are essential for a daily-driver SQL tool.\n\n**Check it out here:**  [https://fasttools.dev/en/sql-playground](https://fasttools.dev/en/sql-playground)\n\nCheers!", "subreddit": "r/SQL", "upvotes": 8, "date": "[PHONE]", "source": "https://www.reddit.com/r/SQL/comments/1sfaer2/browserbased_sqlite_playground_with_realtime_er/"}
{"prompt": "PL/SQL Developer Question", "completion": "PL/SQL Developer Question\nHi all! I tagged this as oracle since I believe that’s the closest SQL format to PL/SQL. I tried to search this, but I’m not sure how to word it, so I’m not getting any hits.\n\nThe data I’m looking at shows charges on an account. When the charge is initiated, column “RECORD\\_TYPE” will say “UNBILLED.” Once the charge is processed, an additional identical line will show up and the column will say “BILLED.” Now I’ve got two similar lines after the charge goes through, with one small difference in the “RECORD\\_TYPE” column. Is there a way to have the results only show one line? I’d love it if there was a way to have the “BILLED” line show up if it was charged but show the “UNBILLED” line if the charge has not been processed yet.\n\nI’ve tried cases and coalesce with no luck, but I may not be thinking of the best way to utilize them. Any advice?", "subreddit": "r/SQL", "upvotes": 8, "date": "[PHONE]", "source": "https://www.reddit.com/r/SQL/comments/1tpeok8/plsql_developer_question/"}
{"prompt": "Migrating Database from On-prem SQL to Google BigQuery PostgreSQL setup. Any pitfalls to watch out for?", "completion": "Migrating Database from On-prem SQL to Google BigQuery PostgreSQL setup. Any pitfalls to watch out for?\nVendor decided for all newer versions of their software, which we need for compliance reasons, will no longer support MS SQL on-prem servers and everything is migrating to BigQuery.\n\nSo I need to update all my Custom Views, Stored Procs, reports, dashboards, etc to pull from the new source and handle PostgreSQL(which I have yet to use for a full project before)\n\nAnybody have any tips or things to watch out for with BigQuery or PostgreSQL?", "subreddit": "r/SQL", "upvotes": 8, "date": "[PHONE]", "source": "https://www.reddit.com/r/SQL/comments/1toa2np/migrating_database_from_onprem_sql_to_google/"}
{"prompt": "best sql courses for someone who writes queries daily and has never designed a table", "completion": "best sql courses for someone who writes queries daily and has never designed a table\nim an analyst. i can write a join in my sleep and ive never created a table from scratch, and my new manager wants me building the model rather than reading one.\n\nshortlisted bootdev, general assembly, pluralsight premium and launch school off a couple of evenings comparing curricula. which of those covers schema design and not just query syntax", "subreddit": "r/SQL", "upvotes": 8, "date": "[PHONE]", "source": "https://www.reddit.com/r/SQL/comments/1wu52es/best_sql_courses_for_someone_who_writes_queries/"}
{"prompt": "Databasus now supports physical backups, WAL streaming and Point-in-Time Recovery for PostgreSQL", "completion": "Databasus now supports physical backups, WAL streaming and Point-in-Time Recovery for PostgreSQL\nHi!\n\nPosting an update about Databasus - an open source self-hosted tool for scheduled database backups, primarily focused on PostgreSQL.\n\nGitHub: [https://github.com/databasus/databasus](https://github.com/databasus/databasus)\nWebsite: [https://databasus.com](https://databasus.com)\n\nTo make Databasus more suitable for disaster recovery and improve backup granularity, we shipped physical backups, incremental backups with continuous WAL archiving and full Point-in-Time Recovery support.\n\n**What's new**\n\nDatabasus now supports three backup types:\n\n* **Logical** \\- the same database dump as before. Works over the network, no extra software needed. Still the best choice for most setups.\n* **Physical** \\- file-level copy of the entire database cluster. Much faster backup and restore for large databases.\n* **Incremental** \\- physical base backup + continuous WAL archiving. This is the one that enables PITR. You can restore your database to any specific second between backups.\n\n**The agent**\n\nPhysical and incremental backups need direct access to database files, so they can't work over a regular network connection. For this we built a lightweight agent in Go that you install alongside your PostgreSQL instance.\n\nThe important part: the agent connects outbound to your Databasus instance, not the other way around. Your database port stays closed. No firewall changes, no VPN tunnels. This was actually a frequently requested feature on its own - people wanted to back up databases in private VPCs and Kubernetes clusters without exposing them publicly.\n\nThe agent works with host-installed PostgreSQL and PostgreSQL in Docker containers. It compresses and streams backups directly to Databasus. It also auto-updates itself, so you don't need to keep it in sync manually.\n\n**How PITR works in practice**\n\nWith incremental backups, the agent continuously streams WAL segments to Databasus. If something goes wrong (bad migration, accidental table drop, data corruption) - you pick a timestamp and restore to that exact moment.\n\nWith daily logical backups you could lose up to 24 hours of data. With incremental backups and PITR, the data loss window is seconds.\n\n**Quick recap for those who haven't seen Databasus before**\n\n* Supported databases: PostgreSQL 12-18, MySQL, MariaDB and MongoDB\n* Storage: S3, Google Drive, Dropbox, SFTP, local disk, Cloudflare R2 and 70+ more via Rclone\n* Notifications: Slack, Discord, Telegram, email, webhooks\n* AES-256-GCM encryption, retention policies (including GFS), health monitoring, workspaces, RBAC and audit logs\n* Single Docker container, Apache 2.0 license, \\~6k GitHub stars, 250k+ Docker pulls\n* No vendor lock-in - backups can be decrypted and restored with just your secret.key, without Databasus itself\n\nThis was the biggest missing piece and I'm happy it's finally out. If you tried Databasus before but decided against it because of no PITR support - it might be worth another look.\n\nHappy to answer any questions.", "subreddit": "r/SQL", "upvotes": 8, "date": "[PHONE]", "source": "https://www.reddit.com/r/SQL/comments/1s0mgdp/databasus_now_supports_physical_backups_wal/"}
{"prompt": "SaaS company agreed to send us nightly backups of our internal DB, but they way they are doing it is very non-standard. Any tips?", "completion": "SaaS company agreed to send us nightly backups of our internal DB, but they way they are doing it is very non-standard. Any tips?\nI'll try to keep this short! I'm a sysadmin, not a DBA, so bear with me lol\n\nWe are looking to expand our reporting capabilities and we've requested data from our cloud software provider. They actually agreed to give us a nightly backup of our MS SQL database used on their backend.\n\nWe don't need to write anything to this database, for our purposes it will be essentially read-only in prod.\n\nThe catch is, they will only send me certain tables that we need for whatever reporting we are doing. That's fine with me, saves on storage.\n\nThey agreed to send me a full backup just once, and I was able to take that and generate a script to build a new db just like it, without the data. Ezpz so far. I have the tables and relations/keys/etc all setup and ready to go.\n\nThe nightly backup is basically a full dump of the tables we've chosen (about 40 tables so far). This is where I'm having issues.\n\nBecause there is no differential or anything I'm just running a giant SQL query that TRUNCATES each table, then insert the new data in from the newly restored backup database they sent.\n\nDoes this sound reasonable?\n\nAnother issue is that me dumping millions of inserts nightly is causing my transaction log to balloon 10GB per night. I've tried to backup and shrink it but it doesn't work. Is there any way around this? It eventually hits my hard limit and forces the db into recovery mode sometimes.\n\nAm I better off dropping the entire DB and rebuilding it from scratch every night? I have all of the scripts needed to automate this ofc.\n\nThanks!", "subreddit": "r/SQL", "upvotes": 8, "date": "[PHONE]", "source": "https://www.reddit.com/r/SQL/comments/1rr60q9/saas_company_agreed_to_send_us_nightly_backups_of/"}
{"prompt": "What are the most commonly asked SQL interview questions and patterns?", "completion": "What are the most commonly asked SQL interview questions and patterns?\nI have an upcoming interview for a analyst role and would like to understand the most commonly asked questions or patterns in the SQL round. Could you please share your experience?", "subreddit": "r/SQL", "upvotes": 8, "date": "[PHONE]", "source": "https://www.reddit.com/r/SQL/comments/1sx67aw/what_are_the_most_commonly_asked_sql_interview/"}
{"prompt": "Optimizing Queries", "completion": "Optimizing Queries\nI am trying to create a view having like around 120 plus columns. Data is being pulled from multiple tables, but the amount of data is around 2.5k rows max and output row count is 2200. Currently its taking 10 seconds for it to get computed. Indexes are added. The main view is being queried from several other views. But I am not sure how to increase the performance. I am quite new to SQL optimization. I am using MySQL Mariadb. Any insights will be helpful", "subreddit": "r/SQL", "upvotes": 8, "date": "[PHONE]", "source": "https://www.reddit.com/r/SQL/comments/1txn6ov/optimizing_queries/"}
{"prompt": "Anyone here managed to significantly cut their Snowflake bill? What actually worked?", "completion": "Anyone here managed to significantly cut their Snowflake bill? What actually worked?\nAnyone here managed to significantly cut their Snowflake bill?\n\nI'm curious about the less-obvious stuff that actually made a noticeable difference.\n\nThings like:\n\n\\- Warehouse sizing / auto-suspend\n\n\\- Query optimization\n\n\\- Clustering\n\n\\- Storage vs compute\n\n\\- Materialized views\n\n\\- Snowflake-specific settings\n\n\\- ETL/ELT architecture changes\n\n\\- Moving workloads elsewhere\n\n\\- Anything you discovered that wasn't obvious initially\n\nIf you've had a meaningful reduction, it'd be great to hear what you changed and roughly how much it saved.\n\nEven small \"I wish I knew this earlier\" tricks are welcome.", "subreddit": "r/SQL", "upvotes": 8, "date": "[PHONE]", "source": "https://www.reddit.com/r/SQL/comments/1wf2ouv/anyone_here_managed_to_significantly_cut_their/"}
{"prompt": "SSIS migration to RDS — Script Components and S3 integration challenges", "completion": "SSIS migration to RDS — Script Components and S3 integration challenges\nWe migrated SSIS packages from EC2-hosted SQL Server to RDS and hit some challenges that only became clear during implementation.\n\nFigured I'd share what broke and see if anyone else has hit similar issues:\n\n\\*\\*1. Script Components don't work in standard RDS\\*\\*\n\nPackages with dynamic column mapping failed immediately. Had to move to RDS Custom (not standard RDS) to get SSIS running properly. Works now, but you lose some of the \"fully managed\" benefits.\n\n\\*\\*2. Migrating from filesystem to S3 storage\\*\\*\n\nWe wanted to move file handling from local filesystem to S3 for better durability and scalability. Challenge: SSIS packages aren't natively S3-aware — they expect filesystem paths or UNC paths. We used AWS Storage Gateway to present S3 buckets through filesystem- style access so existing packages didn't need major rewrites.\n\n\\*\\*3. SQL Agent jobs were polling 24/7 for no reason\\*\\*\n\nWe had jobs running every 2 minutes checking for work. On EC2 this was fine. On RDS it felt wasteful. Switched to event-driven triggers from the app so jobs only run when there's actual work.\n\n\\*\\*Questions for anyone who's done this migration:\\*\\*\n\n\\- Did you go with standard RDS or RDS Custom?\n\n\\- How did you handle file-based SSIS packages (flat file sources, etc.)?\n\n\\- Did you keep SSIS on the database server or split it to a separate EC2 instance?\n\nThe migration worked, but it exposed a lot of assumptions our packages made about having OS-level access. Curious what others ran into.", "subreddit": "r/SQL", "upvotes": 8, "date": "[PHONE]", "source": "https://www.reddit.com/r/SQL/comments/1reejdo/ssis_migration_to_rds_script_components_and_s3/"}
{"prompt": "Portabase (open-source DB backup/restore tool): which databases would you like to see supported?", "completion": "Portabase (open-source DB backup/restore tool): which databases would you like to see supported?\nHi everyone,\n\nI’m one of the maintainers of[ Portabase](https://portabase.io), an open-source, self-hosted platform dedicated to database backup and restore. \n\nRepo:[ https://github.com/Portabase/portabase](https://github.com/Portabase/portabase) (any star would be amazing ❤️)\n\nWe currently support: **PostgreSQL**, **MySQL**, **MariaDB**, **Firebird SQL**, **SQLite**, **MongoDB**, **Redis** and **Valkey.**\n\nWe initially focused on SQL databases and recently started expanding into NoSQL. We’re now looking for feedback from the community on which databases are the most used and which ones would benefit most from being integrated into Portabase.\n\nFYI: support for Microsoft SQL Server is already in progress.\n\n**Key features:**\n\n* Multiple storage options: local, S3, Cloudflare R2, Google Drive\n* Notifications via Discord, Telegram, Slack, etc.\n* Scheduled backups with flexible retention policies\n* Ready-to-use Docker Compose and Helm Chart\n\nSo, which databases would you like to see next?\n\nIf you try Portabase, feel free to open an issue if you run into any bugs or have suggestions.\n\nHappy Easter! 🐇", "subreddit": "r/SQL", "upvotes": 8, "date": "[PHONE]", "source": "https://www.reddit.com/r/SQL/comments/1sd71jj/portabase_opensource_db_backuprestore_tool_which/"}
{"prompt": "If you had 4 months to build a serious PostgreSQL project to learn database engineering, what would you focus on — and what would you avoid?", "completion": "If you had 4 months to build a serious PostgreSQL project to learn database engineering, what would you focus on — and what would you avoid?\nHi everyone,\n\nI’m a software engineering student working on a 4-month final year project with a team of 4, and tbh we’re still trying to figure out what the *right* thing is to build.\n\nI’m personally very interested in databases, infrastructure, and distributed systems, but I’m still relatively new to the deeper PostgreSQL side. So naturally my brain went: *“hmm… what about a small DBaaS-like system for PostgreSQL?”*\nThis is **not** a startup idea and I’m definitely not trying to reinvent Aurora — the goal is learning, not competing.\n\nThe rough idea (and I’m very open to being wrong here): a platform that helps teams run PostgreSQL without needing a full-time DBA. You’d have a GUI where you can provision a Postgres instance, see what’s going on (performance, bottlenecks), and do some basic scaling when things start maxing out. The complexity would be hidden by default, but still accessible if you want to dig in.\n\nWe also thought about some practical aspects a real platform would have, like letting users choose a **region close to them**, and optionally choose **where backups are stored** (assuming we’re the ones hosting the service).\n\nNow, this is where I start doubting myself 😅\n\nI’m thinking about using Kubernetes, and maybe even writing a simple PostgreSQL operator in Go. But then I look at projects like CloudNativePG and think: *“this already exists and is way more mature.”*\nSo I’m unsure whether it still makes sense to build a simplified operator purely for learning things like replication, failover, backups, and upgrades — or whether that’s just reinventing the wheel in a bad way.\n\nWe also briefly discussed ideas like database cloning / branching, or a “bring your own cluster / bring your own cloud” model where we only provide the control plane. But honestly, I don’t yet have a good intuition for what’s realistic in 4 months versus what’s pure fantasy.\n\nAnother thing I’m unsure about is **where this kind of platform should actually run** from a learning perspective:\n\n* On top of a single cloud provider?\n* Multi-cloud but very limited?\n* Or focus entirely on the control plane and assume the infrastructure already exists?\n\nSo I guess my real questions are:\n\n* From a PostgreSQL practitioner’s point of view, what parts of “DBaaS systems” are actually interesting or educational to build?\n* What ideas sound cool but are probably a waste of time or way too complex for this scope?\n* Is “auto-scaling PostgreSQL” mostly a trap beyond vertical scaling and read replicas?\n* If your goal was learning Postgres internals, database operations, and infrastructure, where would you personally put your effort?\n\nWe’re not afraid of hard things, but we do want to focus on the *right* hard things.\n\nAny advice, reality checks, or “don’t do this, do that instead” feedback would really help.\nThanks a lot.", "subreddit": "r/SQL", "upvotes": 7, "date": "[PHONE]", "source": "https://www.reddit.com/r/SQL/comments/1qu3w8x/if_you_had_4_months_to_build_a_serious_postgresql/"}
{"prompt": "Wrote a SQLite like database because it was fun. Give it a try!", "completion": "Wrote a SQLite like database because it was fun. Give it a try!\nHey everyone,\n\nI'm a 4th year CS undergrad, I've been learning about databases since the last year as I eventually wanted to build one. After giving the build several attempts by sometimes building just the storage engine, or the front-end, etc., I finally did complete the build last week. I felt like its ready to share, so I'm making this post here.\n\nRepo: [https://github.com/pixelooz/hinder-db](https://github.com/pixelooz/hinder-db)\n\nIts called HinderDb. It's a cli only (for now) database with a custom slotted page B+Tree storage engine, buffer pool, secondary indexes, wal, volcano style execution pipeline, etc.\n\nI wrote it in rust as I like writing rust and this would be another way to get better at it, plus the domain just seemed like a good fit.\n\nIt was mostly a learning project for me, but ended up better than I had orginally planned for, so I'm quite happy with that. I originally got interested in databases and stuff through Designing Data Intensive Applications book, and since then always wanted to build one. I had already given the storage engine a couple of tries, by reading some already existing material (Writing your own database type of books) and codebases, but this was the first time writing it complete, and its works quite nice.\n\nI am keeping this as my main portfolio project as well since I'll be applying for jobs/intenships. So, if any working professionals can offer any feedback - something I should improve, any apparent flaws, or the next thing I should look into. I'll really appreciate it.\n\nP.S: I have solid knowledge in backend as well and I'll be applying for on-site (in India) as well as global remote positions, so if you can offer any advice regarding navigating the job market rn, it'd be much appreciated.", "subreddit": "r/SQL", "upvotes": 7, "date": "[PHONE]", "source": "https://www.reddit.com/r/SQL/comments/1w3f3ob/wrote_a_sqlite_like_database_because_it_was_fun/"}
{"prompt": "How to find correct CU update for SQL Server", "completion": "How to find correct  CU update for SQL Server\nHi, all,\n\nI'm  trying to update one server with the following version:\n\n|SQL  Version|Product Level|Edition|Update Level|KB Article|\n|:-|:-|:-|:-|:-|\n|[PHONE]|RTM|SQL Server 2019|CU32|KB5068404|\n\non [https://sqlserverbuilds.blogspot.com/](https://sqlserverbuilds.blogspot.com/)  I found this suggestion:\n[CU32](https://sqlserverbuilds.blogspot.com/#sql2019x) ([PHONE], February 2025)\n\nBut version number for CU32 is lower then I see installed, is this the right one ? Or should I stay with old RTM ?\n\nThanks\nVA", "subreddit": "r/SQL", "upvotes": 7, "date": "[PHONE]", "source": "https://www.reddit.com/r/SQL/comments/1rgdxvh/how_to_find_correct_cu_update_for_sql_server/"}
{"prompt": "SQL problem in Visual Studio", "completion": "SQL problem in Visual Studio\ni don t find sql server connector in visual studio (2026) even though everything is downloaded and the connection to the OLE DB Driver for SQL server is successful.\n(Asking for my gf, I'm not really into these stuff so idk if any details are missing)", "subreddit": "r/SQL", "upvotes": 7, "date": "[PHONE]", "source": "https://www.reddit.com/r/SQL/comments/1qt7udv/sql_problem_in_visual_studio/"}
{"prompt": "Help choosing DB schema for an online gadget store - flat tables per device, JSON, or component-based?", "completion": "Help choosing DB schema for an online gadget store - flat tables per device, JSON, or component-based?\nHi everyone,\n\nI'm working on a small online store that sells gadgets - about 5-7 types of devices (smartphones, smartwatches, tablets, etc.).\nNothing crazy big, but users need to filter by stuff like:\n\n* battery life / capacity\n* screen size (inches)\n* display type (OLED, IPS, etc.)\n* processor\n\nNow I'm stuck on how to structure the DB. Here's what I'm considering:\n\n1. **One flat table per device type** \\- like `phones`, `watches`, `tablets` \\- each with its own columns for specs.\n2. **One big** `products` **table with a JSON column** for all the technical details.\n3. **Split into component tables** \\- `displays`, `battery`, `memory`, `network` \\- and link them to products.\n\nI'm leaning toward keeping it simple, but I also want filtering to work well without shooting myself in the foot later.\n\nWhat would you recommend for a real project?\nIs JSON fine for filtering by range (e.g., battery > 4000), or does it get messy?\n\nThanks a ton.\n\nStack: MySQL 8+", "subreddit": "r/SQL", "upvotes": 7, "date": "[PHONE]", "source": "https://www.reddit.com/r/SQL/comments/1tocofx/help_choosing_db_schema_for_an_online_gadget/"}
{"prompt": "Best way to update NULL values?", "completion": "Best way to update NULL values?\nI have data that looks like this:\n\n|Col1|Col2|Col3|\n|:-|:-|:-|\n|A|Two|3|\n|B|Two|NULL|\n|C|Two|NULL|\n|D|Five|NULL|\n|E|Five|6|\n\nWorking in SQL Server, what's the best way to update the NULL values in Col3 to the only non-null value associated with equal values in Col2? e.g. I'd want to update this table to read\n\n|Col1|Col2|Col3|\n|:-|:-|:-|\n|A|Two|3|\n|B|Two|**3**|\n|C|Two|**3**|\n|D|Five|**6**|\n|E|Five|6|", "subreddit": "r/SQL", "upvotes": 7, "date": "[PHONE]", "source": "https://www.reddit.com/r/SQL/comments/1tjylhy/best_way_to_update_null_values/"}
{"prompt": "Can you use google or notes during SQL technical assessment?", "completion": "Can you use google or notes during SQL technical assessment?\nHave a technical interview tomorrow online thats an hour. No idea how difficult it will be but I honestly havent used SQL in years. Been going thru practice questions online and there always some syntax I cant remember but I understand how everything works. Like I’ll remember theres a certain function to do something but I cant remember what it is exactly. Stuff like that where it literally takes me 2 seconds to google and Im back to finishing the code. Not sure how strict SQL technical interviews are about sharing your screen and looking up syntax or using handwritten notes. Thanks in advance.", "subreddit": "r/SQL", "upvotes": 7, "date": "[PHONE]", "source": "https://www.reddit.com/r/SQL/comments/1tcl5t5/can_you_use_google_or_notes_during_sql_technical/"}
{"prompt": "Extract top 100 cases for multiple criteria", "completion": "Extract top 100 cases for multiple criteria\nI have a database having account wise data which goes into millions of records. This data is bifurcated into products.\nI need to build a query to extract top 100 records for each product. Top 100 are to be selected basis descending order of amount balance.\nLooking for ideas to do this.", "subreddit": "r/SQL", "upvotes": 7, "date": "[PHONE]", "source": "https://www.reddit.com/r/SQL/comments/1t3aqxx/extract_top_100_cases_for_multiple_criteria/"}
{"prompt": "just about a sql problem", "completion": "just about a sql problem\nso i ran into this problem in hackerrank while solving sql problems\n\nMan, that was so tough. There is no way a learner is going to solve it by themselves; the edge cases easily got me every single time", "subreddit": "r/SQL", "upvotes": 7, "date": "[PHONE]", "source": "https://www.reddit.com/r/SQL/comments/1ufn3df/just_about_a_sql_problem/"}
{"prompt": "Polyglot playground, transpile SQL across 30+ dialects", "completion": "Polyglot playground, transpile SQL across 30+ dialects\nI came across this wonderful tool today and didn't see it mentioned on Reddit -\n\n[https://polyglot-playground.gh.tobilg.com](https://polyglot-playground.gh.tobilg.com)\n\nand decided to fix that.\n\nTranspile SQL (translates from one DBMS syntax to another, more than 30 dialects), SQL formatting and validation, and other tools. Everything is in the browser (WASM), and as far as I can see, the SQL doesn't go to the server.\n\nA few months ago, I saw a post with a link to a very similar project -\n\n[https://www.reddit.com/r/SQL/comments/1nr90qq/sqlingual\\_free\\_transpiler\\_tool\\_for\\_sql\\_between\\_30/](https://www.reddit.com/r/SQL/comments/1nr90qq/sqlingual_free_transpiler_tool_for_sql_between_30/)\n\nbased on sqlglot, a Python library that is the prototype of Rust's polyglot, but it is no longer available.\n\nI'm not affiliated with this site.", "subreddit": "r/SQL", "upvotes": 7, "date": "[PHONE]", "source": "https://www.reddit.com/r/SQL/comments/1u2b88d/polyglot_playground_transpile_sql_across_30/"}
{"prompt": "CTE vs Subquery vs Temporary Table — what do you prefer?", "completion": "CTE vs Subquery vs Temporary Table — what do you prefer?\nIn real-world projects, when would you choose one over the others? Are there performance considerations that influence your decision?", "subreddit": "r/SQL", "upvotes": 7, "date": "[PHONE]", "source": "https://www.reddit.com/r/SQL/comments/1vlh5fj/cte_vs_subquery_vs_temporary_table_what_do_you/"}
{"prompt": "PostgreSQL database security + Metabase for non-technical users", "completion": "PostgreSQL database security + Metabase for non-technical users\nI have created a PostgreSQL database that currently runs locally and am considering making it accessible to a team of non-technical users.\n\nMy understanding is that PostgreSQL provides security through authentication, roles and permissions, pg\\_hba.conf, firewall/network controls, and SSL/TLS for remote connections. I can create separate users and give them permissions such as SELECT (read-only), INSERT, UPDATE, etc., instead of giving everyone access to the postgres administrator account.\n\nI am also considering using **Metabase** as the interface for the non-technical users. From what I understand, Metabase does not actually host the PostgreSQL database; instead, it connects to PostgreSQL and provides dashboards, visualizations, and a simpler interface for querying the underlying data.\n\nMy proposed setup is:\nPostgreSQL → Metabase → Non-technical users\n\nI would like to understand:\n1. Is Metabase a good option for allowing non-technical users to access PostgreSQL data without directly using pgAdmin or SQL?\n\n2. What is the recommended way to secure the PostgreSQL connection between Metabase and PostgreSQL?\n\n3. Should I create a dedicated read-only PostgreSQL user for Metabase rather than using the postgres account?", "subreddit": "r/SQL", "upvotes": 7, "date": "[PHONE]", "source": "https://www.reddit.com/r/SQL/comments/1vil7a5/postgresql_database_security_metabase_for/"}
{"prompt": "How to start as a beginner?", "completion": "How to start as a beginner?\nHello everyone,\n\nI hope you're all doing well. I've been meaning to learn SQL at home but am just overwhelmed at the moment regarding the process of getting the program on my computer.. There are so many different programs to choose from, and I'm not sure which one to go with. Also  I'm a little confused in regards to the server and client, apparently there are two different things I need to download to be able to start practicing?\n\nIf someone could just provide a clear outline for the installation process I'd really appreciate it.\n\nThank you!", "subreddit": "r/SQL", "upvotes": 7, "date": "[PHONE]", "source": "https://www.reddit.com/r/SQL/comments/1q7y4sv/how_to_start_as_a_beginner/"}
{"prompt": "Career advice, guidance, help from above", "completion": "Career advice, guidance, help from above\nSo… I work a lot with SQL, but I’m terrible at programming languages. Right now I’m a data analyst (though it’s a very loose and broad title). I only have a technologist degree and I feel extremely lost about what to do next.\n\nI think the first step would be to pick a language and learn it properly, like Python. I’ve been thinking about gradually transitioning into engineering... but not sure what's best for me. I really like the data field. I worked for a while building dashboards, but it was brief and not with mainstream tools like Tableau or Power BI. I also want to choose something that will keep me safe in this wave of AI-driven automation, because I believe AI won’t be heavily implemented in the database layer due to process security concerns.\n\nAnyway, I feel stuck and unsure about what step to take now..whether I should pursue a master’s degree, a specialization, follow roadmap.sh, or take an inexpensive online course. Honestly, aside from SQL, I don’t have many technical skills. That makes me anxious. I’d appreciate it if someone wanted to chat and was willing to help. Thanks!", "subreddit": "r/SQL", "upvotes": 7, "date": "[PHONE]", "source": "https://www.reddit.com/r/SQL/comments/1rbw7aa/career_advice_guidance_help_from_above/"}
{"prompt": "Primary Key vs Primary Index (and Unique Constraint vs Unique Index). confused", "completion": "Primary Key vs Primary Index (and Unique Constraint vs Unique Index). confused\nHey everyone,\n\nI’m trying to properly understand this and I think I might be mixing concepts.\n\nFrom what I understood:\n\n* A **primary index** is just an index, so it helps with faster lookups (like O(log n) with B-tree).\n* A **primary key** is a constraint, it ensures uniqueness and not null.\n\nBut then I read that when you create a **primary key**, the database automatically creates a **primary index** under the hood.\n\nSo now I’m confused:\n\n* Are primary key and primary index actually different things, or just two sides of the same implementation?\n* Does every database always create an index for a primary key?\n* When should you explicitly create a unique index instead of a unique constraint?\n\nThank you!", "subreddit": "r/SQL", "upvotes": 7, "date": "[PHONE]", "source": "https://www.reddit.com/r/SQL/comments/1s5zo33/primary_key_vs_primary_index_and_unique/"}
{"prompt": "Interview prep / practice advice", "completion": "Interview prep / practice advice\nHi,\n\nI've been brushing up on my SQL ahead of a technical test for an interview later in the week.\n\nI've been using Codecademy and have completed the analyzing data with SQL skill path.\n\nLooking for suggestions for tasks / queries to practice. My interview is with a retailer and the role is primarily focused on product / category performance could potentially touch on consumer behaviour basket analysis rather than say path to purchase or attribution.\n\nRole has been framed up primarily as stakeholder management and data story telling rather than being a technical specialist so don't know how in the weeds I would need to get.\n\nAny suggestions ideas would be great.", "subreddit": "r/SQL", "upvotes": 7, "date": "[PHONE]", "source": "https://www.reddit.com/r/SQL/comments/1riq0er/interview_prep_practice_advice/"}
{"prompt": "sq v0.53.0 - inspect/query/export databases and generate schema docs from the terminal", "completion": "sq v0.53.0 - inspect/query/export databases and generate schema docs from the terminal\nHey folks - we just shipped **sq v0.53.0**. If you haven't seen **sq** before: it's an open-source CLI for querying, joining, inspecting, importing, and exporting data across **databases + files** using either **native SQL** or a **jq-like pipeline syntax**.\n\nBig additions in v0.53.0: **ClickHouse** support matured considerably; **DuckDB** support is now in beta, including bundled extensions for JSON, Parquet, Excel, HTTPFS, FTS, and more; **Oracle** support is also in beta via a pure-Go driver, so no Instant Client required; and we added **agent skills** so AI assistants can better use `sq` in data-wrangling workflows. There's also a new `--render-sql` flag that shows the SQL generated from an SLQ query, plus richer syntax-error reporting in both text and JSON.\n\n**Why it's useful (real examples):**\n\nWork with files like you do a database:\n\n    cat ./sakila.xlsx | sq .actor --opts header=true --insert .xl_actor\n\nJoin across multiple data sources:\n\n    sq '@report_xlsx.users | join([EMAIL], .user_id) | .name, .order_total'\n\nGo from connect -> inspect -> query quickly:\n\n    sq add clickhouse://user:pass@host:9000/db --handle ch\n    sq inspect\n    sq sql  'SELECT * FROM events LIMIT 10'\n\n**Best SQL Feature?**\n\nThe new feature I think SQL folks will like: `sq inspect` can now generate **.md** and **HTML** schema docs with embedded [entity relationship diagrams](https://sq.io/docs/inspect#markdown). There's also a raw Mermaid ERD output format if you want to drop the diagram into your own docs, wiki, README, AI-agent context, or CI/CD workflow.\n\n    sq inspect  --markdown > schema.md\n    sq inspect  --html > schema.html\n    sq inspect  --format=mermaid-erd > schema.mmd\n\nIf your day involves bouncing between CSVs, Excel files, DuckDB, Oracle, Postgres, MySQL, SQLite, ClickHouse, JSON, or glue scripts you never wanted to write in the first place, we'd love your feedback please!\n\nYou can find **sq** here: [https://sq.io/docs/install](https://sq.io/docs/install)\n\nCode here: [https://github.com/neilotoole/sq](https://github.com/neilotoole/sq)", "subreddit": "r/SQL", "upvotes": 7, "date": "[PHONE]", "source": "https://www.reddit.com/r/SQL/comments/1tsl8k5/sq_v0530_inspectqueryexport_databases_and/"}
{"prompt": "Where to learn SQL", "completion": "Where to learn SQL\nHi everyone,\n\nI have some SQL background as I took a basic SQL class when I was in college as a requirement class. Looking to improve my SQL and learn more, is there any resource I can use to learn SQL as a beginner?\n\nThank you!", "subreddit": "r/SQL", "upvotes": 7, "date": "[PHONE]", "source": "https://www.reddit.com/r/SQL/comments/1uvmi0i/where_to_learn_sql/"}
{"prompt": "Is it really possible to always fit everything into a single query?", "completion": "Is it really possible to always fit everything into a single query?\nI'm \"lazy\" and sometimes use \\`foreach()\\` in PHP to iterate through SQL queries, then manually run individual queries elsewhere based on the data.\n\nOf course, this results in queries that take seconds to run :)\n\nSo here’s my question: Is it really ALWAYS possible to pack everything into a SINGLE query?\n\nI mean, in PHP I can easily “loop” through things, but in phpMyAdmin, for example, I can only run one query at a time, and that’s where I hit a wall...", "subreddit": "r/SQL", "upvotes": 7, "date": "[PHONE]", "source": "https://www.reddit.com/r/SQL/comments/1rtqbql/is_it_really_possible_to_always_fit_everything/"}
{"prompt": "How to recover old sql server", "completion": "How to recover old sql server\n\nHi,\nI'm doing inventory and found one SQL 2017 server which I can not login, and no any history available for it.\nLooks like it's configured only for Local account, so I can't use any AD/Domain accounts.\nDo you know if I can add  NTService/ account directly inside service form?\nor there any other way to login into this account?\nPlease see below pic from SQL Configuration.\n\nThanks\nVA", "subreddit": "r/SQL", "upvotes": 7, "date": "[PHONE]", "source": "https://www.reddit.com/r/SQL/comments/1rk4o83/how_to_recover_old_sql_server/"}
{"prompt": "Test multiple store procedure , how to automate", "completion": "Test multiple store procedure , how to automate\nHi, I need to do A /B testing for 100 MS Procs to run on dbA and dbB and compare results to make sure that at least number of rows is the same.\n\nEach of procs returns different data and  number of columns.  I was trying to use u/rowcount but alas it doesn't work, always returns 0.\nIs there any other relatively simple way to capture number of rows returned after each execution.\nIs this somehow possible ?\nSurely I can create some complex scripts, but I don't want to spend too much time, thinking that that execution stat should be stored somewhere ?\nOr there is some other way ?\n\nTHanks to all for help\n\nVA", "subreddit": "r/SQL", "upvotes": 7, "date": "[PHONE]", "source": "https://www.reddit.com/r/SQL/comments/1sfjnbj/test_multiple_store_procedure_how_to_automate/"}
{"prompt": "How are you managing isolated Postgres database branches for preview deployments /CI?", "completion": "How are you managing isolated Postgres database branches for preview deployments /CI?\nHey everyone, I’m looking at workflows to optimise how we spin up staging databases for app previews. I’ve been expertise Neon’s serverless architecture (specifically looking at how Databricks integrates it for Lakebase) to use its instant database branching.\n\nBeing able to use a Vercel integration to automatically spin up an isolated database branch for a preview deployment, run schema migrations, test a data app and tear it down without duplicating storage costs or impacting production seems like a massive win for modern dev.\n\nFor those running serverless Postgres in production, are you relying heavily on these types of branching workflows, or are you still doing it in the old fashioned way with Docker or isolated RDS staging instances.", "subreddit": "r/SQL", "upvotes": 7, "date": "[PHONE]", "source": "https://www.reddit.com/r/SQL/comments/1u07dem/how_are_you_managing_isolated_postgres_database/"}
{"prompt": "How do you optimize SQL queries that work fine on millions of rows but slow down at billions?", "completion": "How do you optimize SQL queries that work fine on millions of rows but slow down at billions?\nIam interested in learning the techniques data engineers use when datasets grow from millions to billions of records. Beyond basic indexing, what strategies have made the biggest performance difference in production environments?", "subreddit": "r/SQL", "upvotes": 7, "date": "[PHONE]", "source": "https://www.reddit.com/r/SQL/comments/1v1ch04/how_do_you_optimize_sql_queries_that_work_fine_on/"}
{"prompt": "Is there a legit download for MS SQL 2019 developer edition?", "completion": "Is there a legit download for MS SQL 2019 developer edition?\nHello,\n\nI think I can get by with the developer edition but the only version that is supported by their old and new software is 2019.   I found an eval version - not sure if that is the same.  If you have a link  to it on MS's web site I'd greatly appreciate it.\n\nThanks.", "subreddit": "r/SQL", "upvotes": 7, "date": "[PHONE]", "source": "https://www.reddit.com/r/SQL/comments/1ummx2j/is_there_a_legit_download_for_ms_sql_2019/"}
{"prompt": "If the log is the database, and you externalize it, do transactions and analytics end up reading the same copy?", "completion": "If the log is the database, and you externalize it, do transactions and analytics end up reading the same copy?\nMy favorite projects are the ones where the founders took a premise and pushed it until it breaks of pays off. In this case, the premise is old enough to be uncontroversial: the log is the source of truth, and everything else (tables, indexes, replicas, caches) is a materialized view you can rebuild by replaying it. Jay Kreps, who co-created Apache Kafka and later ran Confluent, wrote the general version in his 2013 essay The Log, but Postgres has quietly worked this way for far longer. A commit isn't your rows being rewritten in place, it's a single sequential append to the write-ahead log, and the data files exist only as a cache so reads don't have to replay history from byte zero every time. If you want the primary source rather than the slogan, it's the ARIES paper (Mohan et al., 1992), all 69 pages of it, and the length is earned.\n\nThe interesting exercise is to take that premise literally and follow it one forced step at a time, because each consequence pulls the next one behind it.\n\nStep one: if the log is the truth and the data files are just a cache of it, why do they sit on the same disk? In a stock Postgres box they do, and almost every operational headache traces back to that single colocation:\n\n* Durability is only as good as what your fsync actually did, and fsync has a long history of lying.\n* A read replica is a full physical copy of the database replaying the log.\n* High availability is yet another full physical copy.\n* A heavy analytical scan competes with transactional traffic for the same buffer pool and CPU.\n\nThose look like four unrelated problems, but they're the same problem wearing different clothes: the log and its cache share a machine.\n\nStep two: stop sharing the machine. Pull the two apart into separate services, one owning the log and one owning the pages. This is the part that's actually been built and run in production rather than sketched on a whiteboard, first in Neon's storage engine and now underneath Databricks' Lakebase, which is built on that same engine:\n\n* The write-ahead log moves to a service called the SafeKeeper. A commit becomes durable the moment it's replicated across a Paxos quorum, not when a single local disk claims it flushed, so durability stops being a property of one disk and becomes a network commit.\n* The data files move to a service called the PageServer, which behaves as a write-through cache in front of cloud object storage. On a miss it replays the log from the SafeKeeper to reconstruct the page it needs.\n\nStep three: once both the log and the pages live outside the database process, that process holds no durable state. This is where the consequences start compounding. Stateless compute can be killed, restarted, or forked without losing anything, because the truth was never on that box. Branching a production database stops being a physical copy and becomes a metadata operation you can do in seconds. HA stops meaning \"keep a second full node running and babysit it.\" Storage stops having a ceiling you size against in advance, because underneath it's just object storage.\n\nThe latency objection is the first thing a skeptic reaches for, and it deserves a real answer:\n\n* Writes: you haven't added a network hop. Any Postgres you'd trust in production already runs synchronous replication, which is the same round trip. All that changed is where the acknowledgment comes from", "subreddit": "r/SQL", "upvotes": 7, "date": "[PHONE]", "source": "https://www.reddit.com/r/SQL/comments/1uliao2/if_the_log_is_the_database_and_you_externalize_it/"}
{"prompt": "Schema changes across branches in lakebase", "completion": "Schema changes across branches in lakebase\nI have been using Lakebase sice 2 weeks for developing a serving low latency layer for data in Delta. To build new features we currently make a new branch and later merge ti main.\nWhat i have been observing is the scehema drifts across branches with Lakebase. How do people usually handle such scenarios? To keep branches in sync.\nMaybe some real life examples can help.", "subreddit": "r/SQL", "upvotes": 7, "date": "[PHONE]", "source": "https://www.reddit.com/r/SQL/comments/1vm836g/schema_changes_across_branches_in_lakebase/"}
{"prompt": "DBClient: a native Mac database client for 12 engines (I'm the dev)", "completion": "DBClient: a native Mac database client for 12 engines (I'm the dev)\nI'm the developer of DBClient, a native database client for the Mac (SwiftUI and AppKit, not Electron).\n\n**What it does**\n\n* Connects to PostgreSQL, MySQL, MariaDB, SQLite, SQL Server, Oracle, IBM Db2, MongoDB, Redis, DuckDB, ClickHouse and Databricks.\n* SQL editor with completion from your schema, and a ⌘K palette that jumps to any table.\n* Edit rows right in the grid. You read the exact SQL before anything is committed.\n* Table designers, a schema diagram drawn from your foreign keys, and charts from any result.\n* A console tab running the real psql, mysql or redis-cli, already signed in.\n* Drag a table from one server onto another to copy it, even across engines.\n* SSH tunnels and proxies. Passwords stay in the Keychain, with optional Touch ID.\n* Optional AI assistant with your own API key. It can only run read-only queries.\n\n**Pricing**\n\n* **Free:** the whole app for databases on your own Mac: SQLite and DuckDB files, CSV files, and anything on localhost, Docker included.\n* **Paid:** remote servers need a yearly license, $99 the first year and $49 a year after. If you don't renew, remote connections stop and local ones keep working. It does not renew by itself. One key, one Mac at a time. 30-day refund.\n\n**Privacy:** no account, no analytics. A licensed copy checks its license about once a day. The free copy never contacts the license server.\n\n**Requirements:** macOS 15 or newer, Apple silicon only. Signed and notarized.\n\n[https://dbclient.net](https://dbclient.net) or `brew install --cask az-code-lab/taps/dbclient`", "subreddit": "r/SQL", "upvotes": 7, "date": "[PHONE]", "source": "https://www.reddit.com/r/SQL/comments/1wmi40g/dbclient_a_native_mac_database_client_for_12/"}
{"prompt": "Partitioning or indexing for spark sql?", "completion": "Partitioning or indexing for spark sql?\nIm working with a large tables in spark sql that has around 300 mil records and they are quite wide as well maybe around 80-90 columns.\n\nWe frequently have to perform filtering and aggregations for reporting purposes, I'm trying to understand when should I use partitioning and when should I use indexes.\n\nFor instance if I want to filter by date will it be better to partition by date or should I use an index on the date column, which one would help with performance?", "subreddit": "r/SQL", "upvotes": 7, "date": "[PHONE]", "source": "https://www.reddit.com/r/SQL/comments/1w66j9i/partitioning_or_indexing_for_spark_sql/"}
{"prompt": "I built a terminal-native SQL playground to understand DBMS internals better", "completion": "I built a terminal-native SQL playground to understand DBMS internals better\nWhile using SQL*Plus in my college labs, I realized something—I actually liked working with SQL directly from the terminal. It felt close to the system. But it also felt limiting. You run a query, get results, and everything in between is a black box.\n\nSo I decided to build TermiBase.\n\nIt’s a terminal-native SQL playground focused on learning and transparency. You can run SQL queries and see how they are parsed and logically executed step by step, all inside the terminal. It’s not a full DBMS—more of an educational sandbox to understand what really happens under the hood.\n\nThe project is still evolving, but it’s usable now and open for anyone to try. I’ll be actively updating it and improving the execution explanations over time.\n\nSharing it here in case it’s useful to others who enjoy terminal workflows or are learning databases.", "subreddit": "r/SQL", "upvotes": 6, "date": "[PHONE]", "source": "https://www.reddit.com/r/SQL/comments/1q7xxbr/i_built_a_terminalnative_sql_playground_to/"}
{"prompt": "First time sql user - is this the right setup?", "completion": "First time sql user - is this the right setup?\nHi.\n\nI'm a gamedev. I would also like to get a bit into webdev, if only for personal projects like web apps, games and other interactive media.\n\nI want to make a site that will get something like a bunch of amazon products with their data and store them. The data should be refreshed once per day.\n\nI've never had any contact with backend or databases so I had to ask AI for a tech stack recommendation.\n\nBasically, it says that I can do all that for free. Frontend I can host wherever, for the database it suggested postgres over mysql and suggested using it with supabase.\n\nIt said it was the most generous free tier and I would always stay within limits. It also said that postgres is just better than mysql.\n\nIt also said that I could do cron jobs via github for free to refresh the database.\n\nDoes all this sound about right to you? Still a bit skeptical of llm info, from experience.\n\nSql seems easy to learn the basics of, from a glance. I don't think I'll need more than the basics for this project.\n\nWill learning postgres vs mysql even make a difference for such a simple use case?", "subreddit": "r/SQL", "upvotes": 6, "date": "[PHONE]", "source": "https://www.reddit.com/r/SQL/comments/1qzmu7b/first_time_sql_user_is_this_the_right_setup/"}
{"prompt": "Problems you faced in SQL Preparation Journey", "completion": "Problems you faced in SQL Preparation Journey\nHey\nAs mentioned in my earlier post, I am starting an SQL interview focused site that helps learning sql.\n\nIt works like this\n1. SQL tutorials for preparation\n2. Practice tests for practicing\n3. Interview like tests with timer (postgresql, MySQL and MS SQL)\n\nContext: Learning and acing the SQL for interviews\n\nI want your help in giving me list of issues you faced, you are facing or your juniors may facing\n\nParticularly with websites like sqlbolt, stratascratch, datalemur etc\n\nPlease list them one by one and It will be helpful in creating a global product from India, helping millions of SQL learners.\n\nThanks in advance", "subreddit": "r/SQL", "upvotes": 6, "date": "[PHONE]", "source": "https://www.reddit.com/r/SQL/comments/1rsf6m1/problems_you_faced_in_sql_preparation_journey/"}
{"prompt": "What are the limitations on server roles in SQL Server Express?", "completion": "What are the limitations on server roles in SQL Server Express?\nSo far, the only thing I see is that you can't use the Object Explorer pane on the left to right-click on Server Roles and hit Add New Server Role because it's not there. However, I can still add new server roles via tsql.", "subreddit": "r/SQL", "upvotes": 6, "date": "[PHONE]", "source": "https://www.reddit.com/r/SQL/comments/1rjsvr5/what_are_the_limitations_on_server_roles_in_sql/"}
{"prompt": "Tried dbForge as an SSMS alternative and surprisingly solid", "completion": "Tried dbForge as an SSMS alternative and surprisingly solid\nBeen on SSMS forever, only tried this because a project basically forced me to switch for a bit. Figured I'd write something up since I went in pretty skeptical. \n\nThe autocomplete is actually good. SSMS IntelliSense loses context constantly (aliases in subqueries, complex CTEs, anything nested enough) dbForge Studio for SQL Server just keeps tracking. Not magic, but noticeably more reliable in the situations where SSMS gives up. Which for me is a lot of the day. \n\nAs SSMS doesn't have it natively, I was always reaching for something external. Having it right there cut a real friction point out of release prep. The diff output is readable too, not just a wall of generated SQL you have to decode before acting on it. \n\nTab behavior is a smaller thing but I kept noticing it. After reconnecting, SSMS tabs can act strangely, especially if there are a lot of them open. dbForge keeps state better. It doesn't sound like much, but it adds up over the course of a whole day. \n\nStartup is slower and the UI is busier than SSMS. For quick administration tasks, I still reach for SSMS, that part just fits better.  \n\nBut for actual development work (heavy query writing, comparing environments, prepping a release) it earned its place. Didn't expect to keep using it past the project but here we are. SSMS isn't going anywhere but this sits next to it now. \n\nStill on SSMS as your main thing, or has something shifted that?", "subreddit": "r/SQL", "upvotes": 6, "date": "[PHONE]", "source": "https://www.reddit.com/r/SQL/comments/1sqm34b/tried_dbforge_as_an_ssms_alternative_and/"}
{"prompt": "Is it bad design to have multiple FK columns where only one can be non-null? As to represent origin or cause", "completion": "Is it bad design to have multiple FK columns where only one can be non-null? As to represent origin or cause\nHello, I've always had this question and I couldn't find like a definite answer. Let's say I have a tabla inventory\\_movements. Each movement could come either from a sale, a purchase, a production run or an adjustment. Is it bad design to have columns (sale\\_id, purchase\\_id, production\\_id, adjustment\\_id) where each is a FK and only one could be non-null? Because a movement could not come from both a sale and a purchase. Seeing a whole table full of nulls gives me the impression that it's not a great design, but I can't see any other way of doing it while keeping integrity with fk's.", "subreddit": "r/SQL", "upvotes": 6, "date": "[PHONE]", "source": "https://www.reddit.com/r/SQL/comments/1tczzsi/is_it_bad_design_to_have_multiple_fk_columns/"}
{"prompt": "AWS Glue crawler creating CSV table incorrectly and splitting quoted fields with commas", "completion": "AWS Glue crawler creating CSV table incorrectly and splitting quoted fields with commas\nI'm running into an issue with an AWS Glue crawler and I'm not sure if the problem is the crawler, classifier, or the source file.\n\nI have two CSV datasets with what appears to be the same structure. One dataset is crawled correctly and the other is not.\n\nThe CSV contains values like:\n\n    12345,\"Smith, John\",98765\n\nThe older table was created as:\n\n    ROW FORMAT SERDE 'org.apache.hadoop.hive.serde2.OpenCSVSerde'\n\nand correctly keeps `\"Smith, John\"` in a single column.\n\nThe newer table is consistently created as:\n\n    ROW FORMAT DELIMITED\n    FIELDS TERMINATED BY ','\n\nwith table properties showing:\n\n    classification='csv'\n    areColumnsQuoted='false'\n\nAs a result, fields containing commas are split across columns. For example:\n\n    name_field = Smith\n    id_field = John\n\ninstead of:\n\n    name_field = Smith, John\n\nWhat I've already tried:\n\n* Deleted the Glue table entirely\n* Re-ran the crawler\n* Removed a custom classifier that was previously attached\n* Added a CSV classifier with:\n   * Delimiter = comma\n   * Quote symbol = double quote\n* Deleted and recreated the table through the crawler multiple times\n\nThe crawler still recreates the table as:\n\n    ROW FORMAT DELIMITED\n\nand continues setting:\n\n    areColumnsQuoted='false'\n\nThe crawler is configured to recrawl all files. The source file definitely contains quoted values with embedded commas.\n\nMy questions are:\n\n1. Has anyone seen Glue infer a CSV this way even when quoted fields exist?\n2. Is there a way to force OpenCSVSerde during crawler creation?\n3. Are there known file characteristics that cause Glue to ignore quoted fields and fall back to a simple delimited format?\n4. Is there a way to debug why Glue is deciding `areColumnsQuoted=false`?\n\nAny ideas would be appreciated. I've spent quite a bit of time changing classifiers and recreating the table but the crawler continues to generate the same table definition.", "subreddit": "r/SQL", "upvotes": 6, "date": "[PHONE]", "source": "https://www.reddit.com/r/SQL/comments/1ueoeih/aws_glue_crawler_creating_csv_table_incorrectly/"}
{"prompt": "Request - Problem Solving Frameworks for Leetcode", "completion": "Request - Problem Solving Frameworks for Leetcode\nI’m preparing for a SQL interview. Most of my experience has been basic queries to get the data I need and then transforming/analyzing it in Excel.\n\nI’m currently struggling with deciding HOW to solve problems on leetcode (not syntax; the algorithm). I have Python experience and compared to that, designing a SQL algorithm seems unintuitive. At least with Python it seems easier to break the problem down into manageable, linear, incremental/iterative chunks.\n\nDo any of you follow a framework for tackling SQL problems? If so, what is it?", "subreddit": "r/SQL", "upvotes": 6, "date": "[PHONE]", "source": "https://www.reddit.com/r/SQL/comments/1ueejxm/request_problem_solving_frameworks_for_leetcode/"}
{"prompt": "Best way to avoid environment mixups?", "completion": "Best way to avoid environment mixups?\nThere are a ton of horror stories about people running the updates in the wrong environment, is there a best practice for avoiding this? Can you add a check of an environment variable or the server you should be on against a hard coded text of the environment you should be in?", "subreddit": "r/SQL", "upvotes": 6, "date": "[PHONE]", "source": "https://www.reddit.com/r/SQL/comments/1u8hgks/best_way_to_avoid_environment_mixups/"}
{"prompt": "Solved Hacker Rank's \"15 Days of Learning SQL\" – Looking for different approaches", "completion": "Solved Hacker Rank's \"15 Days of Learning SQL\" – Looking for different approaches\nHi everyone,\n\nI recently solved the HackerRank **15 Days of Learning SQL** challenge using CTE(), `ROW_NUMBER()`, `DENSE_RANK()`, and window functions in SQL Server.\n\nI'm curious to know if there's a cleaner or more efficient way to solve this problem. If you've approached it differently (using other window functions, recursive CTEs, or any other technique), I'd love to see your solution and understand the reasoning behind it.\n\nHere's my solution:\n\n    with daily_submission as(\n    SELECT submission_date,\n    hacker_id,\n    count(*) as total_submission\n    from submissions\n    group by submission_date,hacker_id),\n    hacker_rank as(\n    SELECT submission_date,hacker_id,\n           total_submission,\n           row_number() over(partition by submission_date order by total_submission desc,hacker_id) as rn\n    from daily_submission),\n    continuous_hackers as (\n        SELECT submission_date,hacker_id,\n           dense_rank() OVER(partition by hacker_id order by submission_date) as Dr,\n           datediff(day,'[PHONE]',submission_date) + 1 as contest_day\n    from (\n    SELECT distinct submission_date,hacker_id\n    from submissions) as x),\n    daily_count as (\n    SELECT submission_date,\n            count(*) as total_hackers\n    from continuous_hackers\n    where Dr = contest_day\n    GROUP by submission_date)\n\n\n    SELECT dc.submission_date,\n           dc.total_hackers,\n           h.hacker_id,\n           h.name\n    from daily_count as dc\n    inner JOIN hacker_rank as hr\n    on dc.submission_date = hr.submission_date and rn = 1\n    INNER JOIN hackers as h\n    on hr.hacker_id = h.hacker_id\n    order by submission_date;\n\nThanks in advance! I'm always looking to learn different SQL techniques.", "subreddit": "r/SQL", "upvotes": 6, "date": "[PHONE]", "source": "https://www.reddit.com/r/SQL/comments/1v52nw9/solved_hacker_ranks_15_days_of_learning_sql/"}
{"prompt": "SSMS Connection Timeout (Error 10060) Despite Established TCP Sessions", "completion": "SSMS Connection Timeout (Error 10060) Despite Established TCP Sessions\nWorking on setting up a SQL Server 2019 Standard subscriber for database replication over a site-to-site VPN tunnel. Looking for any additional troubleshooting ideas or confirmation that this is definitively on the remote network side. I am not a SQL expert by any means and unfortanetly we don't have anyone with expertise so looking for some additional insight/help.\n\n**Environment:**\n\n* SQL Server 2019 Standard, default instance\n* Windows Server 2022 Datacenter\n* Site-to-site IPsec VPN between two networks\n* Connecting via SQL Server Authentication\n\n**What we've confirmed working on our side:**\n\n* SQL Server listening on [[IP]:1433](http://[IP]:1433) confirmed via Get-NetTCPConnection\n* Mixed Mode authentication enabled (IsIntegratedSecurityOnly = 0)\n* SQL login exists, is enabled, CHECK\\_POLICY=OFF, CHECK\\_EXPIRATION=OFF\n* Subscriber database ONLINE, MULTI\\_USER\n* SQL Server Agent running, set to Automatic\n* TLS — Trust Server Certificate confirmed on client side, Encryption set to Optional\n* Firewall rules permit TCP 1433 from the remote network range\n* Packet capture running on our server during connection attempts\n* SQL Account/PW correct\n\n**The problem:**\nThe user on the remote network gets Error 10060 (timeout during pre-login handshake) when attempting to connect via SSMS using SQL Server Authentication. Our SQL error log shows zero login failures or connection attempts — nothing at all.\n\nAny ideas appreciated.", "subreddit": "r/SQL", "upvotes": 6, "date": "[PHONE]", "source": "https://www.reddit.com/r/SQL/comments/1uv9hln/ssms_connection_timeout_error_10060_despite/"}
{"prompt": "How much SQL do I need to learn for a technical account manager role at Fintech?", "completion": "How much SQL do I need to learn for a technical account manager role at Fintech?\nI been learning SQL for the past few days because I applied for a TAM role that requires basic SQL query writing, I think it's only part of the job to pull data to troubleshooting payment failurese etc.\n\nWhat I want to know is what is the definition of basic SQL and how much do I actually need to know? I have went through SQLbolt up until lesson 10 because Claude suggested this is enough for this role. But I want to hear from real people as well.\n\nFor context my background is customer service team lead in gaming industry but I been tech-savvy my whole life but did not study anything related to CS. TBH I don't know why they invited me an interview when I lack the technical skills (SQL and API debugging) they require. But I'm learning as much as I can!", "subreddit": "r/SQL", "upvotes": 6, "date": "[PHONE]", "source": "https://www.reddit.com/r/SQL/comments/1vipw8h/how_much_sql_do_i_need_to_learn_for_a_technical/"}
{"prompt": "The same query ran in 30 milliseconds by hand and four seconds from the scheduler [Discussion]", "completion": "The same query ran in 30 milliseconds by hand and four seconds from the scheduler [Discussion]\nPostgres 15. A nightly cleanup job that filters on a status column ran in about 30 milliseconds whenever I tested it in psql, and about four seconds when the scheduler ran it. Same data, same box, same connection parameters. EXPLAIN ANALYZE by hand showed a plain index scan every time and I could not get it to misbehave.\n\nI noticed the split at all because a refactor I was running in verdent kept tripping in-loop verification on one timing assertion, and the failures were not correlated with anything in the diff.\n\nThe thing that answered it was auto\\_explain, with log\\_min\\_duration low and log\\_nested\\_statements on. The query lives inside a PL/pgSQL function, so it does not surface on its own, and the plan the job actually ran was a sequential scan over twenty million rows with an estimate of 3.4 million. My interactive plan estimated 900.\n\nThe function reuses a prepared statement. After five executions Postgres considers the generic plan, which cannot see the literal and estimates average frequency across the six distinct status values rather than the real frequency of failed, which is a few hundred rows. Setting plan\\_cache\\_mode to force\\_custom\\_plan for that function put the job back at 30 milliseconds.", "subreddit": "r/SQL", "upvotes": 6, "date": "[PHONE]", "source": "https://www.reddit.com/r/SQL/comments/1w8urgj/the_same_query_ran_in_30_milliseconds_by_hand_and/"}
{"prompt": "Beginner looking to collaborate on a data analysis project", "completion": "Beginner looking to collaborate on a data analysis project\nI’m a beginner learning data analysis and I want to build a small, practical project, but I’m struggling with choosing a project idea and structuring it properly.\nI’m looking for other beginners / freshers who are also learning and would like to work together, discuss ideas, and build a project as a team.\nTools I’m interested in: Power BI / Python / SQL (beginner level).\nIf this sounds interesting, please comment here. We can plan something simple and realistic.", "subreddit": "r/SQL", "upvotes": 6, "date": "[PHONE]", "source": "https://www.reddit.com/r/SQL/comments/1qs0otc/beginner_looking_to_collaborate_on_a_data/"}
{"prompt": "Query time falls off a cliff if u don't create a temp table halfway through", "completion": "Query time falls off a cliff if u don't create a temp table halfway through\nI'm running into an odd behavior, at least the way I think things work. This is a massive dataset (hospital) and we're using yellow brick which is an onprem columnar data store. This is also an extremely wide table, like 100 columns and is an export.\n\nevery join has the grain worked out so I really don't understand why creating a temp table halfway though and then making the last few joins speeds the query up to 20 seconds vs 15min. Is it just the compiler not finding an efficient plan or is there more to it?\n\npostgress is the closest database that everyone would understand.", "subreddit": "r/SQL", "upvotes": 6, "date": "[PHONE]", "source": "https://www.reddit.com/r/SQL/comments/1qjz87s/query_time_falls_off_a_cliff_if_u_dont_create_a/"}
{"prompt": "Offline data migration: CSV vs Parquet (or other options) moving data from SQL Server to PostgreSQL", "completion": "Offline data migration: CSV vs Parquet (or other options) moving data from SQL Server to PostgreSQL\nHi everyone,\n\nI’m looking for advice from people with experience in SQL Server data migrations, especially in constrained environments.\n\nHere’s the scenario:\n\n\\* I have data stored in \\*\\*SQL Server\\*\\* running on a \\*\\*virtual machine with no internet access\\*\\*.\n\n\\* I need to migrate this data to a \\*\\*PostgreSQL instance hosted on IBM Cloud\\*\\*.\n\n\\* Direct network connectivity between the two systems is not possible.\n\nMy initial idea was to \\*\\*export the data from SQL Server to CSV files\\*\\*, then upload and import them into PostgreSQL on the cloud side. However, I’m wondering if this is really the best approach.\n\nSpecifically:\n\n\\* Would \\*\\*Parquet\\*\\* (or another columnar/binary format) be a better option than CSV for this kind of offline migration?\n\n\\* From your experience, which format is \\*\\*safer in terms of data consistency\\*\\* (types, precision, encoding, null handling)?\n\n\\* Are there \\*\\*better or more robust workflows\\*\\* for an offline SQL Server → PostgreSQL migration that I might be missing?\n\nI’m particularly concerned about avoiding subtle issues like data type mismatches, loss of precision, or encoding problems during the transfer.\n\nAny suggestions, best practices, or war stories are very welcome. Thanks in advance! 🙏", "subreddit": "r/SQL", "upvotes": 6, "date": "[PHONE]", "source": "https://www.reddit.com/r/SQL/comments/1r21ys0/offline_data_migration_csv_vs_parquet_or_other/"}
{"prompt": "Version control for SQL tables: interactive rebase for editing commits mid-rebase", "completion": "Version control for SQL tables: interactive rebase for editing commits mid-rebase\nDolt is a MySQL-compatible database with built-in version control—think Git semantics but for your tables. We just shipped the `edit` action for interactive rebase.\n\nHere's what the workflow looks like in pure SQL:\n\n# Start the rebase:\n\n    CALL dolt_rebase('--interactive', 'HEAD~3');\n\n# Check your rebase plan (it's just a table):\n\n    SELECT * FROM dolt_rebase;\n\n|rebase\\_order|action|commit\\_hash|commit\\_message|\n|:-|:-|:-|:-|\n|1.00|pick|tio1fui012j8l6epa7iqknhuv30on1p7|initial data|\n|2.00|pick|njgunlhb3d3n8e3q6u301v8e01kbglrh|added new rows|\n|3.00|pick|ndu4tenqjrmo9qb26f4gegplnllajvfn|updated rankings|\n\n# Mark a commit to edit:\n\n    UPDATE dolt_rebase SET action = 'edit' WHERE rebase_order = 1.0;\n\n# Continue—rebase pauses at that commit:\n\n    CALL dolt_rebase('--continue');\n\n# Fix your data, then amend:\n\n    UPDATE my_table SET column = 'fixed_value' WHERE id = 1;\n    CALL dolt_commit('-a', '--amend', '-m', 'initial data');\n\n# Finish up:\n\n    CALL dolt_rebase('--continue');\n\nThe use case: you have a mistake buried in your commit history and want to fix it in place rather than adding a \"fix typo\" commit or doing a messy revert dance.\n\nFull blog post walks through an example with a Christmas movies table (and a Die Hard reference): [https://www.dolthub.com/blog/[PHONE]-sql-rebase-edit/](https://www.dolthub.com/blog/[PHONE]-sql-rebase-edit/)\n\nWe also support `pick`, `drop`, `squash`, `fixup`, and `reword`. Still working on `exec`.\n\nHappy to answer questions about the SQL interface or how this compares to other versioning approaches.", "subreddit": "r/SQL", "upvotes": 6, "date": "[PHONE]", "source": "https://www.reddit.com/r/SQL/comments/1qw0qqp/version_control_for_sql_tables_interactive_rebase/"}
{"prompt": "Interview Questions", "completion": "Interview Questions\nHello, I am an accounting and finance analyst with a second round interview coming up this week with a member of the Finance Information Systems team. The application for the position desired strong SQL skills. I disclosed in my application that my SQL experience is intermediate. Due to recent workload shifts, I have been away from it for longer than I’d like and am excited for an opportunity to leverage it again.\n\nWith that said, what sort of questions should I expect to receive regarding SQL? Since my interviewer is in information systems, I’m sure they’re coming. Any feedback is greatly appreciated", "subreddit": "r/SQL", "upvotes": 6, "date": "[PHONE]", "source": "https://www.reddit.com/r/SQL/comments/1s84ebm/interview_questions/"}
{"prompt": "Why not use JOIN in this case?", "completion": "Why not use JOIN in this case?\nIm working through an exercise and I am unsure about the solution.\n\nIn the exercise three tables are used.\nThe given solution looks like this:\n\n    SELECT E.No, Title\n    FROM EVALUATION E, AUDIOTRACK A, DVD D\n    WHERE D.No = E.No AND E.No = A.No AND UID = 'sb' AND Language = 'English' AND Stars = 5 ;\n\nmy question is, why cant I use an explicit natural JOIN, since the attributes that are used in the implicit JOIN all have the same name and data types? Wouldn't it be easier to read? Is it because there are no columns in EVALUATION and DVD that would match Language and Stars from AUDIOTRACK?", "subreddit": "r/SQL", "upvotes": 6, "date": "[PHONE]", "source": "https://www.reddit.com/r/SQL/comments/1rqg4rv/why_not_use_join_in_this_case/"}
{"prompt": "Open source SQL data generator language", "completion": "Open source SQL data generator language\nHello everybody, want to share something I have been working on for the past week called Datasea. It is still no way near finished but it's in a usable state. My idea was to make a programming style language for generating SQL data. It uses a interpreter which you run your file through and that produces a .sql file with the insert methods along with the generated data. Still working on a lot of features I have in mind and also expanding the dataset for generation of fake data. The error system is not ideal will definitely remake that soon. It is also completely open source you can do whatever you want with it. Would love some feedback.\n\n[https://github.com/Ghost9887/datasea](https://github.com/Ghost9887/datasea)", "subreddit": "r/SQL", "upvotes": 6, "date": "[PHONE]", "source": "https://www.reddit.com/r/SQL/comments/1u853u4/open_source_sql_data_generator_language/"}
{"prompt": "What SQL concept became much more important once you started working in data engineering?", "completion": "What SQL concept became much more important once you started working in data engineering?\nIam curious which SQL skills or concepts turned out to be the most valuable in real world data engineering projects compared to what is usually taught in courses.", "subreddit": "r/SQL", "upvotes": 6, "date": "[PHONE]", "source": "https://www.reddit.com/r/SQL/comments/1u67h1k/what_sql_concept_became_much_more_important_once/"}
{"prompt": "I created a game inspired by SQL Murder Mystery and SQL Noir!", "completion": "I created a game inspired by SQL Murder Mystery and SQL Noir!\nI made a browser game called **The SQL Treasure Hunt** where you solve puzzles by writing real SQL queries.\n\nIt's heavily inspired by **SQL Murder Mystery** and **SQL Noir**, but instead of being a detective, you're a pirate searching for a legendary treasure. 🏴‍☠️\n\nYou explore databases, inspect tables, and piece together clues using SQL until you uncover the next part of the adventure. It starts with simple `SELECT` queries and gradually introduces more challenging concepts.\n\nRight now it only has 5 levels made.\n\nI'd really appreciate any feedback:\n\n* Is the difficulty progression good?\n* Are the clues clear enough?\n* Any ideas for future levels or mechanics?\n\nPlay it here:\n[https://thesqltreasurehunt.vercel.app/](https://thesqltreasurehunt.vercel.app/)\n\nThanks! Hope you enjoy it.", "subreddit": "r/SQL", "upvotes": 6, "date": "[PHONE]", "source": "https://www.reddit.com/r/SQL/comments/1vbtd3v/i_created_a_game_inspired_by_sql_murder_mystery/"}
{"prompt": "Restoring/importing SQL databases. SQL 2012 to 2019?", "completion": "Restoring/importing SQL databases.  SQL 2012 to 2019?\nHello,\n\n\nA vendor said we'll need to go to SQL 2019 - we are currently on 2012.    They don't support newer versions of SQL.\n\nI have a new server set up with SQL 2019.\n\nOn the 2012 server - I right clicked, tasks, backup.   I've copied all the backups to the 2019 server.\n\n\nI'm not sure if I attach, restore, import on the 2019 server.   I don't claim to know squat about SQL so don't hesitate to spoon feed your answers.  I'd prefer to use the GUI over powershell if possible.   I imagine it is straight foward but I thought I'd talk to people who know a lot more about this before I just googled it.", "subreddit": "r/SQL", "upvotes": 6, "date": "[PHONE]", "source": "https://www.reddit.com/r/SQL/comments/1uouqxk/restoringimporting_sql_databases_sql_2012_to_2019/"}
{"prompt": "[MS SQL] Is Change Tracking best for a large ERP database?", "completion": "[MS SQL] Is Change Tracking best for a large ERP database?\nWe run a large ERP database on SQL Server 2014 Standard with about 40k SKUs and their associated inventory records, prices, orders, and order lines. We're considering enabling SQL Server Change Tracking for a read-only \"middleware\" connection to other outside systems we're building (Hubspot, Shopify, etc).\n\nIs Change Tracking the best option for this use case? Are there better alternatives or something else we should test/evaluate?", "subreddit": "r/SQL", "upvotes": 6, "date": "[PHONE]", "source": "https://www.reddit.com/r/SQL/comments/1vxe1pc/ms_sql_is_change_tracking_best_for_a_large_erp/"}
{"prompt": "Looking for BA contributors for an open-source SQL Database Testing / TDD project", "completion": "Looking for BA contributors for an open-source SQL Database Testing / TDD project\nHi everyone,\n\nI'm working on an open-source project focused on building a **Python/pytest automated testing framework for a SQL database**, with a **TDD approach**.\n\nI'm looking for people interested in contributing from a **Business Analysis perspective**, particularly by creating **Business Requirements, Master Stories and User Stories** for different parts of the framework and database testing approach.\n\nThe project currently covers areas such as:\n\n* SQL Stored Procedures\n* Database Views\n* Tables\n* Database Constraints\n* CI/CD integration\n\nThe goal is to make the project a practical example of how **BA requirements can be translated into User Stories → Acceptance Criteria → automated tests**, specifically for SQL database development and testing.\n\nIf this sounds interesting, feel free to contribute to the GitHub project or comment/message me.\n\nI'm also interested in feedback from BAs, QAs, developers and database professionals on how the requirements and User Stories could be structured better.", "subreddit": "r/SQL", "upvotes": 6, "date": "[PHONE]", "source": "https://www.reddit.com/r/SQL/comments/1wpby2x/looking_for_ba_contributors_for_an_opensource_sql/"}
{"prompt": "Looking for resources to learn to optimize sql query", "completion": "Looking for resources to learn to optimize sql query\nHi. I am looking for any best resources like books, videos or courses on sql performance optimization that I can reference. Or where did you learn optimization techniques in sql?\n\nAI is good. But, I want to learn from something reliable like videos or books. Plus, AI is not allowed or block at work.\n\nto have more context, I am a data analyst, so basically I pulled reports from mysql. I always request to add index to DBA since I don't have access to do it but he denied and told me to optimize the queries instead. He also mention it might slow down the WRITES process.\n\nThank you.", "subreddit": "r/SQL", "upvotes": 6, "date": "[PHONE]", "source": "https://www.reddit.com/r/SQL/comments/1qcyt2l/looking_for_resources_to_learn_to_optimize_sql/"}
{"prompt": "Can someone please tell me what I'm doing wrong here? This is a lab I'm working on (not graded)", "completion": "Can someone please tell me what I'm doing wrong here? This is a lab I'm working on (not graded)\n\nI'm working on this lab for my Database management class and this lab has got me stumped. I get the table, but the name of the employee and the name of the manager aren't matching up.", "subreddit": "r/SQL", "upvotes": 6, "date": "[PHONE]", "source": "https://www.reddit.com/r/SQL/comments/1q54vh8/can_someone_please_tell_me_what_im_doing_wrong/"}
{"prompt": "Do visual diagrams help with SQL schema review, or are they just noise?", "completion": "Do visual diagrams help with SQL schema review, or are they just noise?\nI’ve been working on a tool that converts SQL schemas into interactive diagrams for teams to visually review structure, relationships, and changes.\n\nI’m trying to understand whether the lack of interactive diagrams is a common problem ppl have.\n\nFor those who work with SQL schemas, could you help me to understand:\n\n* How do you review schema changes?\n* Do visual representations give any insight, or do you rather rely on raw SQL diffs?\n* What would make a tool like this more useful in a team setting?\n\nLinking the current implementation purely for context: [sqlestev.com/dashboard](http://sqlestev.com/dashboard)", "subreddit": "r/SQL", "upvotes": 6, "date": "[PHONE]", "source": "https://www.reddit.com/r/SQL/comments/1qx0ece/do_visual_diagrams_help_with_sql_schema_review_or/"}
{"prompt": "Convert European date format to SQL format", "completion": "Convert European date format to SQL format\nHi, I tried to write the European date format to the database using a SUBSTR conversion (I had previously converted it manually using a PHP function):\n\n`SELECT SUBSTR(\"[PHONE]\",-4)+'-'+SUBSTR(\"[PHONE]\",4,2)+'-'+SUBSTR(\"[PHONE]\",1,2) AS EuropeanDate2MySQLDate;`\n\nStrangely enough, it seems to treat all three strings as numbers and add them together instead of concatenating them?! Does anyone know why?\n\n>Result: 2048 (instead of [PHONE]).\n\nI managed to do it using CONCAT after all, but isn't there really a more elegant solution?\n\n    SELECT CONCAT(\n        RIGHT(\"[PHONE]\",4),\n        '-',\n        MID(\"[PHONE]\",4,2),\n        '-',\n        LEFT(\"[PHONE]\",2)\n    );", "subreddit": "r/SQL", "upvotes": 6, "date": "[PHONE]", "source": "https://www.reddit.com/r/SQL/comments/1ry4fh8/convert_european_date_format_to_sql_format/"}
{"prompt": "Zero-ETL search (BM25, vector) over remote Parquet/Iceberg in Postgres SQL", "completion": "Zero-ETL search (BM25, vector) over remote Parquet/Iceberg in Postgres SQL\nIf you want to run BM25 ranking or vector search on data lakes (over remote data), you usually have to move or copy that data into a search engine or a dedicated database. \n\nI've prepared a [short demo](https://github.com/serenedb/serenedb/tree/main/examples) on how you can search over remote data directly from SQL.\n\nFor context:\n\nI'm working on a Postgres-compatible search-OLAP database called SereneDB and we've just recently pushed this \"Zero-ETL\" feature to our repo and are looking for feedback! \n\nSpecifically, I'm curious:\n\n1. Do you find this Zero-ETL thing useful?\n2. Does the SQL interface feel natural for BM25/ranking?", "subreddit": "r/SQL", "upvotes": 6, "date": "[PHONE]", "source": "https://www.reddit.com/r/SQL/comments/1tdslg2/zeroetl_search_bm25_vector_over_remote/"}
{"prompt": "Can solve basic SQL, but LeetCode Easy/DataLemur Easy feels impossible. How do I develop SQL problem-solving skills?", "completion": "Can solve basic SQL, but LeetCode Easy/DataLemur Easy feels impossible. How do I develop SQL problem-solving skills?\nHi everyone,\nI can write basic SQL queries without much trouble—SELECT, WHERE, GROUP BY, HAVING, joins, aggregates, etc. If you ask me what a function does, I usually understand it.\nThe problem starts when I try LeetCode Easy or DataLemur Easy questions.\nI read the question and often have no idea where to begin. Even when I know the SQL concepts involved, I struggle to translate the business problem into a query. Sometimes I look at the solution afterward and think, *“That makes sense, I could have understood that,”* but I wouldn’t have come up with it myself.\nThis is making me question whether:\nMy SQL fundamentals are actually weak\nI need coaching or a structured course\nI’m lacking general problem-solving skills rather than SQL knowledge\nFor those who were in a similar position:\nHow did you develop SQL problem-solving intuition?\nDid you follow a structured roadmap or just solve lots of questions?\nHow long did it take before interview-style SQL questions started feeling natural?\nAny specific resources, courses, or practice methods you’d recommend?\nI’d appreciate advice from people who went from “I know SQL syntax” to “I can actually solve SQL interview questions.”\nThanks!", "subreddit": "r/SQL", "upvotes": 6, "date": "[PHONE]", "source": "https://www.reddit.com/r/SQL/comments/1u86n9v/can_solve_basic_sql_but_leetcode_easydatalemur/"}
{"prompt": "OData SSIS project will not accept \"Edm.GeographyPoint\" columns", "completion": "OData SSIS project will not accept \"Edm.GeographyPoint\" columns\nI've ensured that my software is completely up to date, but my SSIS project (that uses OData as a source), will just refuse to accept data where one of the columns is the Edm.GeographyPoint type. I've tried entering specific columns into the query box (and therefore excluding the problem column), but it appears it will still throw an error, despite the data itself not containing any columns of that data type - I'm assuming it's downloading the column metadata for the entire table, seeing a data type it doesn't recognise, and throws an error.\n\nI've tried using a different collection that doesn't have columns of that data type, and the SSIS project works with that - the problem is, there doesn't appear to be any way of fixing this. I've ensured the software is completely up to date.", "subreddit": "r/SQL", "upvotes": 6, "date": "[PHONE]", "source": "https://www.reddit.com/r/SQL/comments/1v3b2v7/odata_ssis_project_will_not_accept/"}
{"prompt": "How are folks QA’ing AI agents?", "completion": "How are folks QA’ing AI agents?\nLots of folks at my company use Claude Code to do analysis. When I ask whether the query is right, I get wishy washy responses at best. Anybody have good tools or processes? Or every person for themselves?", "subreddit": "r/SQL", "upvotes": 6, "date": "[PHONE]", "source": "https://www.reddit.com/r/SQL/comments/1vy4ak3/how_are_folks_qaing_ai_agents/"}
{"prompt": "Tired of SQL/dev work—is it worth sticking with long-term, or should I pivot?", "completion": "Tired of SQL/dev work—is it worth sticking with long-term, or should I pivot?\nHey everyone,\nI’m getting pretty tired of my SQL-heavy dev role and SSIS packages, Azure, jobs, etc\n\nI’m wondering if you think **S**QL is going to be super valuable/lucrative in the future, or should I start looking into other paths? (Not sure if it is even that lucrative now or ever has been).\n\nIs there another skillset I should consider?\n\nIf I do pivot, what other jobs do people usually jump to from IT?\n\nWould love your thoughts!", "subreddit": "r/SQL", "upvotes": 6, "date": "[PHONE]", "source": "https://www.reddit.com/r/SQL/comments/1vwpy7d/tired_of_sqldev_workis_it_worth_sticking_with/"}
{"prompt": "Newer to SQL and recently inherited code", "completion": "Newer to SQL and recently inherited code\nMight not be a standard request but does anyone have any best practices for interpreting other people's code if they don't leave a fair amount of notes?", "subreddit": "r/SQL", "upvotes": 6, "date": "[PHONE]", "source": "https://www.reddit.com/r/SQL/comments/1wjyhg1/newer_to_sql_and_recently_inherited_code/"}
{"prompt": "How to build month-on-month booking reports from SAP tables when there is no change log?", "completion": "How to build month-on-month booking reports from SAP tables when there is no change log?\nHi everyone,\n\nI’m fairly new to SQL and reporting, and I need some guidance on a booking report problem using SAP data.\n\nAt my organization, SAP is used as the ERP system. The SAP backend tables are already available in our data lake. I can see raw tables like VBAK, VBAP, VBKD, etc.\n\nHow the data looks:\n\nWhen a sales order is changed (quantity change, value change, cancellation), the old record is not deleted.\n\nInstead, a new record is added with a change date.\n\nSo the tables contain multiple versions of the same order/item with different change dates.\n\nWhat I need to build:\n\nA month-on-month bookings report that shows only the net change for each month, not the full order value every time. Also if the sales order is deleted what would be the ideal case.\n\nExample:\n\nDecember 2025:\n\nCustomer A orders a pump\n\nPrice = 5,000 USD\n\nQuantity = 5\n\n→ December booking = 25,000 USD\n\nJanuary 2026:\n\nCustomer increases quantity from 5 to 10\n\n→ January booking should show +25,000 USD (only the increase)\n\nFebruary 2026:\n\nif the order is rejected in erp or deleted\n\n→ February booking should show -50,000 USD (to reverse previous bookings)\n\nSo the report should reflect:\n\nDecember: +25k\n\nJanuary: +25k\n\nFebruary: -50k\n\nMy confusion:\n\nSince SAP stores multiple records with different change dates, I’m not sure:\n\nHow to compare the current record with the previous one\n\nHow to calculate the monthly difference correctly and also offset complete value in the current reporting month in case of order deleted in the current month.\n\nWhether I should take monthly snapshots or calculate deltas between records\n\nMy questions:\n\nWhat is the usual approach to calculate month-on-month bookings from SAP tables like VBAK/VBAP?\n\nIs the **snapshot** method recommended in this case?. if so how to achieve this.\n\nAre there any simple explanations, examples, or documentation for beginners on this topic?\n\nGiven that I only know basic SQL and Power BI, what would be a practical way to start?\n\nAny advice or learning resources would really help. Thanks a lot!", "subreddit": "r/SQL", "upvotes": 6, "date": "[PHONE]", "source": "https://www.reddit.com/r/SQL/comments/1qn0g39/how_to_build_monthonmonth_booking_reports_from/"}
{"prompt": "SQL Server IoT 2025 is Here: What It Is and Why It Matters for Embedded and OEM Systems", "completion": "SQL Server IoT 2025 is Here: What It Is and Why It Matters for Embedded and OEM Systems\nThe new [SQL Server IoT 2025](https://www.arrow.com/ais/msembedded/products-and-offerings/sql-server/sql-server-iot-2025) is now available! If you build devices, appliances, or embedded systems that ship with a database inside, SQL Server IoT 2025 is worth a serious look. It brings the SQL Server 2025 engine into long-life, fixed-function products. You get the full engine, the same AI features, the same JSON and vector capabilities, and the same security improvements. The only difference is that it is packaged and licensed for OEM and embedded scenarios.\n\nIn my experience supporting embedded customers, the pattern is consistent. More data at the edge, tight security requirements, long product lifecycles, and pressure to support AI without adding cloud dependencies. SQL Server IoT 2025 helps you handle those problems without changing how you design your systems. You can use the same T-SQL, drivers, tools, containers, and development workflow.\n\n# AI where your device runs\n\nThe biggest change in SQL Server IoT 2025 is the built-in AI stack. The database now supports a native vector type, semantic search, hybrid search, and local or remote model execution. You can generate embeddings inside the engine, and you can run AI agents through a secure REST endpoint that SQL Server manages.\n\nNothing in this requires a cloud connection unless you choose to use one. You can keep models local by using Ollama or ONNX Runtime. You can also call cloud models through Azure OpenAI or OpenAI.\n\nFor embedded systems, this means you can build features that previously required a cloud round-trip. Examples include local anomaly detection, troubleshooting assistance, natural language search of manuals or logs, and smarter automation. If you already store your device data in SQL Server, the new vector features let you use that data immediately.\n\n# Security that matches modern requirements\n\nThe platform is secure out of the box. SQL Server IoT 2025 carries forward the security updates from SQL Server 2025. That includes TLS 1.3, TDS 8.0, PBKDF hashing, managed identities, and stricter defaults. This helps you ship hardware that is ready for audit and compliance checks. For teams in healthcare, manufacturing, or other controlled industries, this reduces significant design risk.\n\n# Performance improvements that help small systems\n\nMost devices in the field run on constrained compute, so predictable behavior underload becomes more important than raw horsepower. SQL Server IoT 2025 benefits from improvements like optimized locking, Lock After Qualification, tempdb governance, faster failover, and reduced contention during heavy workloads.\n\nYour device can run more predictable workloads with fewer stalls. It starts faster, handles concurrency better, and gives you cleaner behavior when something on the system misbehaves.\n\n# Better ways to move data out of the device\n\nYou also get Change Event Streaming, which pushes changes directly to Azure Event Hubs. The engine streams committed transactions without extra system tables. This helps when your design needs low-latency reporting or coordination with services outside the device.\n\nIf you use Microsoft Fabric, SQL Server IoT 2025 supports database mirroring directly into OneLake. That gives you a simple path to analytics or long-term storage without writing ETL code.\n\n# Developer workflow stays simple\n\nStability in the toolchain is just", "subreddit": "r/SQL", "upvotes": 6, "date": "[PHONE]", "source": "https://www.reddit.com/r/SQL/comments/1qicbjd/sql_server_iot_2025_is_here_what_it_is_and_why_it/"}
{"prompt": "SQL test for Marketing Analyst", "completion": "SQL test for Marketing Analyst\nI've applied for a marketing analyst position at Agoda and they're gonna test my SQL skills (among others) through an online test\n\nThe SQL part of the test lasts 15 min. What sort of functions/topics do you think are gonna be more likely to be there?\n\nIs it more likely to be 2 long queries or many short ones?\n\nIt's my first time doing a SQL test as part of a job application, any tips are highly appreciated!", "subreddit": "r/SQL", "upvotes": 6, "date": "[PHONE]", "source": "https://www.reddit.com/r/SQL/comments/1qez6ac/sql_test_for_marketing_analyst/"}
{"prompt": "sql hacker rank assessment in the screening process, what and where should i practice ?", "completion": "sql hacker rank assessment  in the screening process, what and where should  i practice ?\nI in the process for a jr data analyst and a bit lost on what i should focus on\n\nthe company is a fintech for that provides  micro loans and credit cards", "subreddit": "r/SQL", "upvotes": 6, "date": "[PHONE]", "source": "https://www.reddit.com/r/SQL/comments/1q8gum6/sql_hacker_rank_assessment_in_the_screening/"}
{"prompt": "[mysql] Learner here - How thorough am I supposed to be when cleaning data?", "completion": "[mysql] Learner here - How thorough am I supposed to be when cleaning data?\nSo I'm doing my first independent practice project. I downloaded a small csv file from maven analytics (movie rating) ~17k rows, 1 table...\n\nAnyway, I started doing cleaning the data column by column and all is fine. Now I'm at a column called \"studio_name\" and within it are well, studio names. So I did a basic group by, count(*) and it returned over 1000 rows. Well, ok. So I decided to check the studio name with one of the highest count returned\n\nso I wrote a query where it started as \"warne%\" just to filter out all the variations and they alone had 20+ rows.\n\nWarner Bros. Pictures, Warner Bros, Warner Brothers, Warner Bros Pictures and amongst them were different legit warner bros studios like warner bros. animations etc...\n\nSo I checked few other companies as well, paramount, universal etc... and they were all similar, legit studio variations in addition to some glaring small grammar issues.\n\nHow granular should I even go when cleaning this data? I can't even possibly know all the studios and all the variations between them?\n\nEven if I knew every single studio name by heart, it would take me days to properly clean just this one column.\n\nI'm asking what is the typical practice amongst you guys who have been doing this professionally. Do you try to fix everything, at what point do you start and end?\n\nI have many other questions but I'll leave them for another time.\n\nMy initial thought was to do a basic analysis of movies per studio. If I had a revenue or any other metric I'd include them, but all I have here is a count of no. of movies per studio. So I'd group them by a count threshold then merge most if not all the \"lesser\" studios into the bigger ones if they fail to meet that threshold in addition to including the obvious studio names with grammatical errors.\n\nIs this a valid solution?\n\nThanks and I appreciate your help", "subreddit": "r/SQL", "upvotes": 6, "date": "[PHONE]", "source": "https://www.reddit.com/r/SQL/comments/1q7btf3/mysql_learner_here_how_thorough_am_i_supposed_to/"}
{"prompt": "Draw a line or deliver product", "completion": "Draw a line or deliver product\nWhere do u draw the line in the request is just not possible  because the data entry of it is not consistent. I have been dealing with making a fact table for close to a month now and it’s so difficult  because staff aren’t doing what they should be doing and there are so many gray areas. I can get close but it’s not 100 percent. Its on authorizations and they are supposed to expire before starting a new one, but then sometimes it can be simultaneous and sometimes switches codes or sometimes the new auth overlaps the old auth expiry by 30 days or more. It’s like they aren’t following the rules they  have and while understand why they want this report  as some visibility to this problem , is better than none but this time I feel like it’s manual excel data sift -that is awful I hate to tell them but do I really deliver a report  that I know has failures. Or do I tell them of the failures and say here ya go you have been warned I just know this back fires on me eventually. I have showed them where and why it fails and how I can’t protect against every single thing and they get it but man I don’t like the idea of it not being right", "subreddit": "r/SQL", "upvotes": 6, "date": "[PHONE]", "source": "https://www.reddit.com/r/SQL/comments/1rwsc3x/draw_a_line_or_deliver_product/"}
{"prompt": "Any quick tool to check for ANSI-SQL in my Query?", "completion": "Any quick tool to check for ANSI-SQL in my Query?\nHello!\nI am a student and we learn SQL at school. I would say I'm already pretty good. But when I or my classmates write SQL, our teacher often says some Syntax or Keywords are specific or atleast different in certain DBMS like MySQL or Oracle or PostgreSQL etc.\n\n\nFor HTML there is [The W3C Markup Validation Service](https://validator.w3.org/) to paste your HTML into and check if it's valid.\n\nIs there something like that but for SQL that takes a Query and not only check for it's validity, but also if it's pure ANSI-SQL which should work in any DBMS? So I also learn to write SQL that generally works (and only use specific SQL if there's a benefit to that).", "subreddit": "r/SQL", "upvotes": 6, "date": "[PHONE]", "source": "https://www.reddit.com/r/SQL/comments/1rs3488/any_quick_tool_to_check_for_ansisql_in_my_query/"}
{"prompt": "Beginner Help Please!", "completion": "Beginner Help Please!\nhello everyone, I’m a complete beginner to SQL (I’m using dbeaver) and need help understanding this question that was asked while practicing! “Firstly you will connect to the empty database provided and populate the database with the CSV files”. (I was provided with 4 CSV files). Does the empty database mean an empty SQL script or something else entirely?\n\nThanks in advance", "subreddit": "r/SQL", "upvotes": 6, "date": "[PHONE]", "source": "https://www.reddit.com/r/SQL/comments/1u5rm7i/beginner_help_please/"}
{"prompt": "I made a SQL puzzle game - looking for feedback!", "completion": "I made a SQL puzzle game - looking for feedback!\nFair warning up front: this is my first time building anything like this, I'm not a web dev, and it's a passion project with zero monetization. So I'd really value the feedback of people who know SQL. I am a DB admin by day, but I am not super familiar with cryptography puzzles.\n\nDisclaimer, most of the CSS was written with AI assistance.\n\nThe premise: you're working a \"signals desk\" and every intercepted message is hidden inside a small database. The goal is to write a query that reconstructs the original text, and the moment your result contains the message, it decrypts. It runs entirely in your browser (SQLite via WebAssembly) with no backend or sign-up process.\n\nIt's an eight-puzzle ladder, each one introducing one new idea built on the last: WHERE → ORDER BY + group\\_concat → joins → char/unicode math → modulo → multi-join → CTEs → window functions, then a gated boss that stitches several of them into one query. I will say that the \"boss\" level is meant to be very challenging and not exactly intuitive.\n\nIt's fully client-side, so a determined player can read the answers out of the tables by inspecting the webpage. That's intentional, if you want to \"cheat\" you can do so. What rewards doing it the \\*intended\\* way is a set of optional \"objective\" stars (e.g. did your answer actually flow from the key table, or did you hardcode a constant?).\n\nLink: [https://cipherquery.io](https://cipherquery.io)\n\nWhat I'd most like to know: \\*\\*which puzzle lost you, and where did the difficulty spike feel wrong?\\*\\* I suspect the last few levels ramp too hard. A daily-challenge mode is planned, so I'm trying to get the core curve right first, and what's acceptable in a puzzle sense.\n\nDon't hold back if you want to tear it apart, this is a learning experience for me.", "subreddit": "r/SQL", "upvotes": 6, "date": "[PHONE]", "source": "https://www.reddit.com/r/SQL/comments/1ty4ur3/i_made_a_sql_puzzle_game_looking_for_feedback/"}
{"prompt": "Made a small VS Code extension for browsing/querying databases (Trino, Postgres, Supabase, SQLite, DuckDB, MySQL) — sharing in case it's useful to someone", "completion": "Made a small VS Code extension for browsing/querying databases (Trino, Postgres, Supabase, SQLite, DuckDB, MySQL) — sharing in case it's useful to someone\nI kept switching out to a separate DB client just to check a table or run a quick query, so I put together a small VS Code extension to save myself the context switch. Sharing it here in case it's useful to anyone else — it's nothing fancy, just:\n\n1: A connection tree in the sidebar (databases → tables/views → columns) with DDL preview\n\n2: Run a query with Cmd/Ctrl+Enter, or just the selected statement, results in a grid\n\n3:A few saved connections side by side (dev/staging/prod), switch which one's active\n\n4: Paste a JDBC string or connection URL and it tries to fill in the form\n\n5: Passwords go into VS Code's Secret Storage rather than settings.json\n\nIt supports **Trino, PostgreSQL, Supabase, SQLite, DuckDB, and MySQL** right now — still rough around the edges in places, and I'm sure there are gaps I haven't hit yet.\n\nMarketplace: https://marketplace.visualstudio.com/items?itemName=big-tech-talk.trino-explorer\n\nIf you try it and hit something broken or confusing, I'd genuinely appreciate the feedback", "subreddit": "r/SQL", "upvotes": 6, "date": "[PHONE]", "source": "https://www.reddit.com/r/SQL/comments/1vncbvz/made_a_small_vs_code_extension_for/"}
{"prompt": "End-to-end Enterprise E-Commerce Analytics", "completion": "End-to-end Enterprise E-Commerce Analytics\nOver the past few days, I built an end-to-end Enterprise E-Commerce Analytics Platform using SQL Server, Medallion Architecture, and Power BI.\n\nAs part of this project, I designed 8 interactive dashboards, each focused on answering different business questions for different stakeholders across an organization.\n\nThe dashboards include:\n\n• Executive Overview (CEO, CXO & Business Leadership)\n\n • Sales Performance Analysis\n\n • Customer Analytics\n\n • Product Performance\n\n • Seller Performance\n\n • Payment Analytics\n\n • Customer Satisfaction Analysis\n\n • Time Intelligence & Trend Analysis\n\nThe goal wasn't just to build visually appealing dashboards—it was to create a reporting solution that helps businesses make faster and more informed decisions.\n\nIn this post, I've shared all 8 dashboards.\n\nI'd genuinely appreciate your feedback.\n\nAs experienced BI professionals, data analysts, data engineers, or business leaders, I would love to hear your thoughts.\n\nIf you could review the dashboards and share at least three suggestions for improvement, it would mean a lot to me.\n\nFor example:\n\n• Are the KPI cards meaningful and business-focused?\n\n • Are the charts and visualizations appropriate for executive reporting?\n\n • Are there too many or too few visuals?\n\n • Would you recommend different filters or slicers?\n\n • Is the overall layout clean, intuitive, and enterprise-ready?\n\n • What would you change if this dashboard were used in your organization?\n\nI'm continuously learning, and constructive feedback is one of the best ways to improve. Every suggestion will help me build better enterprise BI solutions in the future.\n\nThank you for taking the time to review my work. I truly appreciate your support and feedback.\n\n— [Himansh Upadhyay](https://www.linkedin.com/feed/update/urn:li:activity:7489165036213436416/#)\n\n**#PowerBI** **#SQLServer** **#DataAnalytics** **#BusinessIntelligence** **#DataWarehouse** **#DataEngineering** **#MedallionArchitecture** **#StarSchema** **#DAX** **#ETL** **#Analytics** **#DashboardDesign** **#EnterpriseAnalytics** **#DataVisualization** **#SQL**", "subreddit": "r/SQL", "upvotes": 6, "date": "[PHONE]", "source": "https://www.reddit.com/r/SQL/comments/1vcgvmu/endtoend_enterprise_ecommerce_analytics/"}
{"prompt": "What real-world data scenarios do you think beginners should know about?", "completion": "What real-world data scenarios do you think beginners should know about?\nWhat real-world data scenarios do you think beginners should know about?\n\nI’ve been putting together a series called **“Data Analysis 101 for Cat People”**, where I use hand-drawn doodles to explain some of the practical, messy, and ambiguous situations that come up in data work.\n\nThe idea is less about teaching SQL or tools and more about helping someone new to data understand the **real-world thinking behind the work** — asking better questions, dealing with ambiguity, understanding requirements, interpreting what the data is (and isn’t) telling you, and turning messy situations into clear next steps.\n\nI’m also putting these together as a newsletter on Substack - https://thedatadoodles.substack.com\n\nFor those of you who work with data: what are some situations you’ve encountered that you think someone starting out should be familiar with?\n\nI’d be happy to hear your examples and experiences.", "subreddit": "r/SQL", "upvotes": 6, "date": "[PHONE]", "source": "https://www.reddit.com/r/SQL/comments/1wasurk/what_realworld_data_scenarios_do_you_think/"}
{"prompt": "SQL optimization advice for large skewed left joins in Spark SQL", "completion": "SQL optimization advice for large skewed left joins in Spark SQL\n dealing with serious SQL performance problem in Spark 3.2.2. My job runs a left join between a large fact table (\\~100M rows) and a dimension table (\\~5M rows, \\~200MB). During the join, some tasks take much longer than others due to extreme skew, and sometimes the job fails with OOM.\n\nI already increased executor memory to 16GB, which helped temporarily. I enabled AQE (spark.sql.adaptive.enabled = true), but the skew join optimization never triggers. I also tried broadcast join hints, but Spark still chooses a shuffle join. Using random suffixes to redistribute data inflated the size 10x and caused worse memory issues.\n\nMy questions.\n\n*   Why would Spark refuse to apply a broadcast join when the table looks small enough? Could data types, nulls, or statistics prevent it?\n*   Why does AQE not detect such a clear skew, and what exact conditions are needed for it to activate?\n*   Beyond memory increases and random suffix hacks, what real SQL-level optimization strategies could help, like repartitioning, bucketing, custom partitioning, or specific Spark SQL configs?\n*   Any practical experience or insights with large skewed left joins in SQL / Spark SQL would be very helpful.", "subreddit": "r/SQL", "upvotes": 5, "date": "[PHONE]", "source": "https://www.reddit.com/r/SQL/comments/1qo7vpw/sql_optimization_advice_for_large_skewed_left/"}
{"prompt": "SQL Server 2025 help", "completion": "SQL Server 2025 help\nHi everyone, anybody ever have any issues downloading SQL server 2025 on Windows ARM? I’m taking a college class right now and need this program but I’m having issues installing it. Anything I could do? Thank you.", "subreddit": "r/SQL", "upvotes": 5, "date": "[PHONE]", "source": "https://www.reddit.com/r/SQL/comments/1qj8oq9/sql_server_2025_help/"}
{"prompt": "High CPU Utilization", "completion": "High CPU Utilization\nSo we are using a AWS lightsail ubuntu 20.04 instance, 16GB RAM, 4vCPU.\n\nIt hosts both the application written in PHP and a MySQL 8 database.\n\nAround 2 days back, the utilization of MySQL has increased to 100%\n\nI've enabled slow queries and have optimized most read queries by adding an index. But as this utilization issue didn't occur previously with the same data load, I can't seem to figure out the root cause.", "subreddit": "r/SQL", "upvotes": 5, "date": "[PHONE]", "source": "https://www.reddit.com/r/SQL/comments/1q79ae1/high_cpu_utilization/"}
{"prompt": "Insert into multiple tables using CTEs (SQL Cookbook 4.6)", "completion": "Insert into multiple tables using CTEs (SQL Cookbook 4.6)\nSQL Cookbook has no solution for MySQL, PostgreSQL, or SQL server. I chose the Postgres flair, because that is what I am using, but I suspect this might work on other DBMS as well:\n\nCreate the tables based on an existing table:\n\n    create table dept_a as select * from dept where 1=0;\n    create table dept_b as select * from dept where 1=0;\n    create table dept_c as select * from dept where 1=0;\n\nPopulate the tables from the original table:\n\n    with foo as (\n      insert into dept_a (deptno, dname, loc)\n      select * from dept\n      returning *\n    ), bar as\n      (insert into dept_b (deptno, dname, loc)\n      select * from foo\n      returning *\n    )\n    insert into dept_c (deptno, dname, loc)\n    select * from bar;", "subreddit": "r/SQL", "upvotes": 5, "date": "[PHONE]", "source": "https://www.reddit.com/r/SQL/comments/1rrtca0/insert_into_multiple_tables_using_ctes_sql/"}
{"prompt": "Need some suggestions", "completion": "Need some suggestions\ni know excel, Power Bi,Sql,and also python but i am not understanding whether its enough to land for data analytics job , i am not understanding that what amount of knowledge would be enough for data analytics roles, pls help me in it, it would be great if you mention topic wise and their preparation level", "subreddit": "r/SQL", "upvotes": 5, "date": "[PHONE]", "source": "https://www.reddit.com/r/SQL/comments/1s9grby/need_some_suggestions/"}
{"prompt": "Looking for a tool to monitor connectivity between two MS SQL DBs.", "completion": "Looking for a tool to monitor connectivity between two MS SQL DBs.\nI am using MS SQL in the Cloud and locally. The cloud one talks the local one all day. We find that some employees get a slow connection and or the connection times out for them, while others are not having any issues.\n\nWe have tested the connection between then and other sites on the internet and there is no issues. The cloud MS SQL reside in AWS, and the office is on 500/500Mbit fiber.\n\nThanks,", "subreddit": "r/SQL", "upvotes": 5, "date": "[PHONE]", "source": "https://www.reddit.com/r/SQL/comments/1u19g5p/looking_for_a_tool_to_monitor_connectivity/"}
{"prompt": "Where does Lakebase fit in your architecture?", "completion": "Where does Lakebase fit in your architecture?\nfor people using Lakebase, what role does it play in your tech-stack?\nIs it replacing your traditional OLTP database, sitting besides your data lake or mainly used for supporting AI workloads?\nCurious how people are using it in real peod architecture.", "subreddit": "r/SQL", "upvotes": 5, "date": "[PHONE]", "source": "https://www.reddit.com/r/SQL/comments/1v7vzt7/where_does_lakebase_fit_in_your_architecture/"}
{"prompt": "Built a Sales Management System using SQL Server | Looking for Feedback", "completion": "Built a Sales Management System using SQL Server | Looking for Feedback\nHi everyone,\n\nI recently completed my second SQL portfolio project: \\*\\*Sales Management System\\*\\*.\n\nThe goal of this project was to practice intermediate SQL concepts by building a relational database and solving real-world business problems.\n\n\\### What this project includes\n\n• 8 relational tables\n\n• Primary Key & Foreign Key relationships\n\n• Sample business data\n\n• 50+ SQL queries\n\n• SQL Views\n\n• Business reporting queries\n\n• Professional documentation\n\n• GitHub repository with screenshots\n\n\\### SQL concepts used\n\n\\- SELECT\n\n\\- WHERE\n\n\\- ORDER BY\n\n\\- GROUP BY\n\n\\- HAVING\n\n\\- INNER JOIN\n\n\\- LEFT JOIN\n\n\\- RIGHT JOIN\n\n\\- UNION\n\n\\- INTERSECT\n\n\\- EXCEPT\n\n\\- Aggregate Functions\n\n\\- CASE\n\n\\- String Functions\n\n\\- Date Functions\n\n\\- Views\n\nI'm currently learning SQL to build my portfolio and would really appreciate any feedback or suggestions on improving the project.\n\nGitHub Repository:\n\n[https://github.com/Pushkarnegi-dev/SQL-Sales-Management-System](https://github.com/Pushkarnegi-dev/SQL-Sales-Management-System)\n\nThank you!", "subreddit": "r/SQL", "upvotes": 5, "date": "[PHONE]", "source": "https://www.reddit.com/r/SQL/comments/1uy1l9n/built_a_sales_management_system_using_sql_server/"}
{"prompt": "Where should a shared business definition live when the same SQL metric appears in many reports?", "completion": "Where should a shared business definition live when the same SQL metric appears in many reports?\nWhen revenue, active users, retention, or another derived metric is repeated across dashboards and exports, copying the SQL makes every consumer independent but lets definitions drift. Centralizing it in a view, materialized view, semantic layer, dbt model, or stored function creates one definition, but can hide performance costs and make change control harder. What criteria determine where that logic belongs? I would compare ownership, testability, query-plan visibility, versioning, parameter needs, refresh timing, and whether downstream users must inspect the exact calculation. How do you change a widely used definition without silently rewriting historical reports?", "subreddit": "r/SQL", "upvotes": 5, "date": "[PHONE]", "source": "https://www.reddit.com/r/SQL/comments/1w269bl/where_should_a_shared_business_definition_live/"}
{"prompt": "I wrote a guide for scheduling Snowflake workspace notebooks with Snowflake Tasks", "completion": "I wrote a guide for scheduling Snowflake workspace notebooks with Snowflake Tasks\nno I do not work for snowflake\n\n[https://gist.github.com/ben-nour/d20d21657d185df3d34f717faeef65c0](https://gist.github.com/ben-nour/d20d21657d185df3d34f717faeef65c0)", "subreddit": "r/SQL", "upvotes": 5, "date": "[PHONE]", "source": "https://www.reddit.com/r/SQL/comments/1vmufss/i_wrote_a_guide_for_scheduling_snowflake/"}
{"prompt": "A globe with PostgreSQL events", "completion": "A globe with PostgreSQL events\nJust for fun made a globe with PostgreSQL events: [https://pg.whitetown.com](https://pg.whitetown.com) \\- known conferences, meetups and user groups since 2001, with a year slider.\nMobile friendly, but for the full experience use IE4 :-). Feedback welcome - especially if something is missing or wrong.", "subreddit": "r/SQL", "upvotes": 5, "date": "[PHONE]", "source": "https://www.reddit.com/r/SQL/comments/1vl79zu/a_globe_with_postgresql_events/"}
{"prompt": "I made a free retro Win95 Theme SQL game to practice by solving murder mysteries & crime cases", "completion": "I made a free retro Win95 Theme SQL game to practice by solving murder mysteries & crime cases\nHey SQL learners and data enthusiasts!\n\nI built **SQL Detective**, a free interactive web game aimed at making practicing SQL fun instead of grinding boring tutorial tables.\n\n🕵️‍♂️ **Play for free in your browser**: [https://sql-detective.rauchrodrigues.in](https://sql-detective.rauchrodrigues.in)\n\n# Why I built it:\n\nWhen learning SQL, doing static exercises with mock employee tables gets dry quickly. I wanted to create something where every query feels like analyzing evidence to solve a mystery.\n\n# Features:\n\n* **Real SQLite Engine**: Runs completely in your browser via SQLite WASM (no registration or setup required).\n* **Nostalgic Win95 UI**: Complete with terminal window, schema explorer, interactive ER diagram visualizer, and retro audio.\n* **Progressive Difficulty**: Cases start from basic `SELECT` and `WHERE` filters to complex `JOIN`s, `GROUP BY`, and nested subqueries.\n\nGive it a spin and let me know what you think or if you run into any bugs/cases you'd like added!", "subreddit": "r/SQL", "upvotes": 5, "date": "[PHONE]", "source": "https://www.reddit.com/r/SQL/comments/1wlkai1/i_made_a_free_retro_win95_theme_sql_game_to/"}
{"prompt": "Managing a semantic/context layer for data analytics", "completion": "Managing a semantic/context layer for data analytics\nAt a previous job as a data analyst I manually built a \"context\" layer in Notion to feed to Claude when querying databases. This was painfully manual though, involved a lot of work to slowly build up - I would get Claude to document a table/column when I encounter it for the first time on a new task. The Notion page included things like metrics, conventions and product docs too.\n\nFor more experienced data analysts, how do you guys deal with this? Is there a tool you guys use, or is a manual workaround like mine the norm?", "subreddit": "r/SQL", "upvotes": 5, "date": "[PHONE]", "source": "https://www.reddit.com/r/SQL/comments/1whm756/managing_a_semanticcontext_layer_for_data/"}
{"prompt": "Resume thoughts for NGs", "completion": "Resume thoughts for NGs\nI’ve been working fo 8 years now, but I still remember how difficult NG job hunting was. I sent out hundreds of resumes back then and barely got interviews. Things only became easier after landing my first role.\n\nOver the years, I’ve interviewed many candidates and also hired a few myself. With the current market, NGs are clearly facing a tougher environment, so I wanted to share a few practical resume-related observations.\n\n**1. Resumes are about passing filters first**\n\nFor NGs, it’s normal not to fully match a job description. Most candidates only match a small portion of the JD.\n\nFrom what I’ve seen, resumes that clearly reflect relevant tools, languages, and systems listed in the JD tend to survive automated screening. Even limited exposure (coursework, projects, internships, personal work) is worth highlighting if it aligns with the role.\n\nThe most important thing is getting past the initial screen and into an interview, where you can actually present your personality and skills\n\n**2. Put relevant keywords early**\n\nAs an interviewer,  we don’t read resumes line by line.\n\nWe usually focus on:\n\n* the first one or two experiences\n* the first one or two bullets\n* the beginning of each bullet\n\nIf the JD emphasizes specific tools or technologies, put those near the top of your resume. Metrics and impact are nice, but for NGs, relevance matters more.\n\n**3. Interviews matter more than resumes**\n\nOnce you get an interview, expectations for NGs are generally reasonable. Interviewers mainly want to see that you understand the basics and can communicate clearly.\n\nFor behavioral questions companies like to ask you can find on [Glassdoor](https://www.glassdoor.com/index.htm)**/**[BLIND](https://www.teamblind.com/)\n\nFor Technical round you can find real questions on [PracHub](https://prachub.com/)\n\nThis is just personal experience. The process is hard, I really hope this helps more people.\n\nGood luck to everyone job hunting.", "subreddit": "r/SQL", "upvotes": 5, "date": "[PHONE]", "source": "https://www.reddit.com/r/SQL/comments/1qnb1bz/resume_thoughts_for_ngs/"}
{"prompt": "Uploading huge JSON file into mySQL database through PHP", "completion": "Uploading huge JSON file into mySQL database through PHP\nOK guys this might be stupid problem but I'm already bouncing off the wall so hard the opposite wall is getting closer with every moment.\n\nI need to upload very big JSON file into mySQL database to work with. File itself has around 430MB. The file itself is some public gov file pregenerated so I can't actually make it any more approachable or split into couple smaller files to make my life easier (as well as there is another problem mentioned a little later). If you need to see the mentioned file it is available here - [https://www.podatki.gov.pl/narzedzia/white-list/](https://www.podatki.gov.pl/narzedzia/white-list/) \\- so be my guest.\n\nThe idea is to make a website to validate some data with the data from this particular file. Don't ask why, I just need that, and it can't be done any different way. I also need to make it dumb friendly so anyone basically should just save the desired file to some directory and launch the webpage to update the database. I already did that with some other stuff and it if working pretty fine.\n\nBut here is the problem. File itself has over 3 mil rows and there is actually no database I have around, internal or external, which can get this file uploaded without error. I always get the error of\n\n`Fatal error: Allowed memory size of 536870912 bytes exhausted (tried to allocate 910003457 bytes) in json_upload.php`\n\nNo matter the memory limit I set, the value needed is always bigger. So the question is. Is there any way to deal with such big JSON files? I read that they are designed to be huge but looks like not so much. I messed with the file a little and when I removed the data until around 415MB left it uploaded without any errors. I used to work with raw CSV files which are much easier to deal with.\n\nOr maybe you have any hint what you do if you need to throw in such big data to database from a JSON file?\n\nThanks.", "subreddit": "r/SQL", "upvotes": 5, "date": "[PHONE]", "source": "https://www.reddit.com/r/SQL/comments/1qk1f7a/uploading_huge_json_file_into_mysql_database/"}
{"prompt": "How do you guys update tables?", "completion": "How do you guys update tables?\nI try to update my schema (if it is right way to call) which contains tens of table, and each table contains from tens to hundreds of columns.\n\nI try to find a way to automate updating schema procedure. But I found that if I want to do so, I need to type all the column name one by one. And it feels very inefficient to do so.\n\nFor me since I use duckDB, easiest way is convert table to dataframe and handle it with pandas. But I want to know how others handle such a situation and expand my knowledge.", "subreddit": "r/SQL", "upvotes": 5, "date": "[PHONE]", "source": "https://www.reddit.com/r/SQL/comments/1qi083q/how_do_you_guys_update_tables/"}
{"prompt": "any tips for a beginner struggling with correlated subquery", "completion": "any tips for a beginner struggling with correlated subquery\nstarting on sql zoo but i’ve been struggling with correlated subquery something about understanding how the aliases work is tripping me up a lot, im a little frustrated because ive looked through this sub and eveyone seems to find sql so easy but it been taking me a little bit to grasp each concept i learn. can anyone give me a few tips or explain to me in stupid people terms how correlated subquery work and where i may use them ?", "subreddit": "r/SQL", "upvotes": 5, "date": "[PHONE]", "source": "https://www.reddit.com/r/SQL/comments/1q47zq0/any_tips_for_a_beginner_struggling_with/"}
{"prompt": "pg_ash – See what your Postgres was doing 10 minutes ago (pure SQL, no C extension)", "completion": "pg_ash – See what your Postgres was doing 10 minutes ago (pure SQL, no C extension)\nActive Session History for any Postgres — RDS, Supabase, self-managed, whatever. Samples wait events every second, stores them with zero bloat using partition rotation. Query the past with plain SQL, no C extension needed.", "subreddit": "r/SQL", "upvotes": 5, "date": "[PHONE]", "source": "https://www.reddit.com/r/SQL/comments/1resm2w/pg_ash_see_what_your_postgres_was_doing_10/"}
{"prompt": "Need to learn but actually apply it", "completion": "Need to learn but actually apply it\nI feel like I read about sql and do practices in videos and stuff enough to where I understand the basics. I’ve done stuff like sql case files or sql bolt and I get it. But I’m running into the classic circle of “I need experience to get jobs but I need jobs to get experience”.\n\nWhat resources do you guys suggest to bridge the gap from just learning to actually doing?", "subreddit": "r/SQL", "upvotes": 5, "date": "[PHONE]", "source": "https://www.reddit.com/r/SQL/comments/1qv7av9/need_to_learn_but_actually_apply_it/"}
{"prompt": "A recent medical graduate that is keen on learning SQL (alongside Pandas and Python)? Any use in freelancing?", "completion": "A recent medical graduate that is keen on learning SQL (alongside Pandas and Python)? Any use in freelancing?\nI generally started learning Python as a hobby not so long ago and found out i actually love it. Coming from a small country in Europe i'm now in an (unpaid) intern year and some money would be useful, so i was wondering if there's any use for these (for now future) qualifications since this situation could last a whole year. Are they useful skills or actually \"not that special, there's many who already know that\".\n\nSorry for the ignorance, i've tried researching into Medical data analytics and similiar freelance jobs, but since it's a pretty niche field it's kinda hard to find first hand info on starting. I understand it takes some time to learn these programs.\n\nThanks in advance", "subreddit": "r/SQL", "upvotes": 5, "date": "[PHONE]", "source": "https://www.reddit.com/r/SQL/comments/1rpg6d5/a_recent_medical_graduate_that_is_keen_on/"}
{"prompt": "How do you validate schema changes before deploying to production?", "completion": "How do you validate schema changes before deploying to production?\nIn a lot of teams I still see database changes going to production with very little validation.\n\nSometimes it's just someone reviewing the migration script and hoping nothing breaks.\nOther teams use schema comparison or some checks in CI before deploying. How does it work in your team? How do you validate schema changes before they hit production?", "subreddit": "r/SQL", "upvotes": 5, "date": "[PHONE]", "source": "https://www.reddit.com/r/SQL/comments/1rm860c/how_do_you_validate_schema_changes_before/"}
{"prompt": "Help me with Oracle version", "completion": "Help me with Oracle version\nHi everyone,\n\nI need advice on setting up Oracle for learning.\n\nMy friend is a data analyst currently working in government, but he wants to move into banking or remote roles at international companies. He has a Lenovo T14s Gen 5 (Windows 11, 16–32GB RAM).\n\nThis will be his first time installing and using Oracle.\n\nWhich Oracle version would you recommend for:\n\n* Learning SQL + real-world use\n* Being relevant for bank / enterprise environments\n* Helping with future remote job opportunities", "subreddit": "r/SQL", "upvotes": 5, "date": "[PHONE]", "source": "https://www.reddit.com/r/SQL/comments/1suhmlt/help_me_with_oracle_version/"}
{"prompt": "I am a senior IT student, stuck while doing my senior project", "completion": "I am a senior IT student, stuck while doing my senior project\nSo I am currently doing CLP with a company and I have to develop a project for them.\n\nLong story short, I have to create a pl/sql package that generates xml files and sends them by email as a part of it.\n\nI did the logic and the procedures for one of the scenarios but when I checked it with data that should be loaded into the file, it started to skip over some parts of the code and the files generated became corrupted.\n\nAny idea what is the solution for these? All the chats with the AI it talks about the buffer size and suggests solutions that don’t work.\n\nI am already down with the whole war things here, still hoping to graduate ✌🏻✌🏻", "subreddit": "r/SQL", "upvotes": 5, "date": "[PHONE]", "source": "https://www.reddit.com/r/SQL/comments/1slp3fq/i_am_a_senior_it_student_stuck_while_doing_my/"}
{"prompt": "I am an IC for a legacy .NET MVC app in the process of refactoring it and I need to know more about performance tuning and optimizing DBs.", "completion": "I am an IC for a legacy .NET MVC app in the process of refactoring it and I need to know more about performance tuning and optimizing DBs.\nHi, I have been working on this .NET with MSSQL project for more than 9 months now and I have learnt a lot refactoring back-end part of the code but the database is something I am afraid to touch as it's SP heavy application with more than 500+ SPs with business logic crammed into SP. Now the goal is not a complete rewrite but to know enough to not fuck things up in prod or staging, I am weak with indexing concepts, I know indexing helps DBs run faster but also impact inserts and deletes will be slower if I try to index everything. I want to know where can I learn more of this? cause honestly, I don't think there are any courses that would teach this.\nI am not refactoring all of the SPs but just the hot ones that are hit more often and take time and consume more resources to execute.\n\nI saw Brent Ozar's video on \"How to think like an SQL engine\" and it did help me in some way but when I see the SPs written in the app it's beyond scary, each of them are at the very least 200+\n lines, I want to know if someone has been in this situation and how did you manage to resolve this and what I should know before working and optimizing the DBs, I just have basic-intermediate knowledge about MSSQL in general.", "subreddit": "r/SQL", "upvotes": 5, "date": "[PHONE]", "source": "https://www.reddit.com/r/SQL/comments/1uh2jdd/i_am_an_ic_for_a_legacy_net_mvc_app_in_the/"}
{"prompt": "sysbench Analysis on TideSQL v4.5.6 & InnoDB in MariaDB v11.8.6", "completion": "sysbench Analysis on TideSQL v4.5.6 & InnoDB in MariaDB v11.8.6\nLSM engine advantage shown through sysbench analysis comparing with InnoDB on near config parity.  Do check it out!", "subreddit": "r/SQL", "upvotes": 5, "date": "[PHONE]", "source": "https://www.reddit.com/r/SQL/comments/1u2itgd/sysbench_analysis_on_tidesql_v456_innodb_in/"}
{"prompt": "Finished SQLbolt and mode/thoughtspot, where do I go next?", "completion": "Finished SQLbolt and mode/thoughtspot, where do I go next?\nLearning SQL to go into data analyst and eventually scientists.\n\nI went through SQLbolt and mode/thoughtspot education material, where can I enhance or train my sql skills next?", "subreddit": "r/SQL", "upvotes": 5, "date": "[PHONE]", "source": "https://www.reddit.com/r/SQL/comments/1v86l3s/finished_sqlbolt_and_modethoughtspot_where_do_i/"}
{"prompt": "How do you manage cost on managed Postgres services like Neon?", "completion": "How do you manage cost on managed Postgres services like Neon?\nMy team is evaluating managed Postgres options such as Neon for creating AI based apps. What strategies do you follow yo keep cost in control? Do you rely on its flagship features such as scaling, branching or something else.\n\nAny real life production experience/lessons learnt is helpful..", "subreddit": "r/SQL", "upvotes": 5, "date": "[PHONE]", "source": "https://www.reddit.com/r/SQL/comments/1uq1vye/how_do_you_manage_cost_on_managed_postgres/"}
{"prompt": "Which type of SQL should I learn and master if I want to become a data analyst?", "completion": "Which type of SQL should I learn and master if I want to become a data analyst?\nAfter doing some research on google, I found out that there a lot of different types of sql (eg: mysql, postgresql, T-sql, etc). My question is, which type of sql should I learn and master if I want to become a data analyst?", "subreddit": "r/SQL", "upvotes": 5, "date": "[PHONE]", "source": "https://www.reddit.com/r/SQL/comments/1vjscu8/which_type_of_sql_should_i_learn_and_master_if_i/"}
{"prompt": "Best practices for documenting, storing, and collaborating for an automation project involving SQL", "completion": "Best practices for documenting, storing, and collaborating for an automation project involving SQL\nWhat are the best practices for documenting, storing, and collaborating for an automation project involving SQL?\n\nI recently agreed to do an automation project for a company I’ve done normal process improvement and project management in the past, but this will be the first project where I’ll be using SQL to automate data extraction and transformation for different people in the organization. The database already gets daily updated, but I've been the only one using it so far. Also, there’s a chance that another person joins me in this project, so I want to have the right structure and documentation in place.\n\nSo far, I’ve been using DBeaver and have my queries saved locally at my computer. I export all queries to the same folder. I’ve developed no documentation at all.\n\nI do have kept the SQL code with comments, but I’m looking for tips such as:\n\n\\-Where and how to save the .sql files\n\n\\-Should I have a documentation file or read me or something somewhere? What normally goes to it?\n\n\\-Is GitHub something that fits into a project like this? How?", "subreddit": "r/SQL", "upvotes": 5, "date": "[PHONE]", "source": "https://www.reddit.com/r/SQL/comments/1r89bxr/best_practices_for_documenting_storing_and/"}
{"prompt": "SQL with AI assistant", "completion": "SQL with AI assistant\nWe are using GitHub copilot at work and i am curious how people's experience with it is? I am not sure if i am using it incorrectly or maybe not using the correct model but i find the AI to be a fine code writer in a vacuum but terrible in general. what i mean is that it's like someone who knows all the rules of SQL in an ideal world, without any database knowledge.\n\nI work with multiple large relational and dynamic databases and without understanding the complexities of the database and how inconsistent the data entry is (sometimes i have to pull the same data from multiple tables because end users find fun new ways to enter data), it does a terrible job.\n\nI've tried to update some old clunky stored procedures that are accurate but slow, and the output rows were reduced by 75%.\n\nI have found success in it helping me with micro code writing \"i need a case statement to do this\" but can't get it to be truly functional.\n\nI'd love to gear your feedback :-)", "subreddit": "r/SQL", "upvotes": 5, "date": "[PHONE]", "source": "https://www.reddit.com/r/SQL/comments/1r2yxw9/sql_with_ai_assistant/"}
{"prompt": "Built a Chrome extension to visualize SQL flow / lineage in web-based SQL editors", "completion": "Built a Chrome extension to visualize SQL flow / lineage in web-based SQL editors\nHi r/SQL,\n\nI built a Chrome extension called **SuperFLOW** and recently launched it on the Chrome Web Store.\n\nThe main goal is simple: make complex SQL easier to understand visually.\n\nIt turns SQL into a graph so you can inspect things like:\n\n* sources and CTEs\n* joins, filters, and subqueries\n* outputs and write targets\n* column-level lineage\n* multi-statement dependencies\n\nIt works best in **Superset SQL Lab**, but I also designed it to support other web-based SQL editors on a best-effort basis. There’s also a clipboard / paste fallback for cases where direct editor access is limited.\n\nI built this because reading long legacy SQL line by line is slow, especially when I just want to answer questions like:\n\n* Where does this CTE come from?\n* What does this output depend on?\n* Which upstream columns feed this column?\n* How are multiple statements connected?\n\nRight now, I’d especially love feedback on:\n\n* whether the graph model feels useful for real-world SQL\n* what kinds of queries are hardest to understand\n* what edge cases you’d test first\n* whether table/CTE flow or column lineage is more valuable in day-to-day work\n\nChrome Web Store:\n[https://chromewebstore.google.com/detail/superflow/jndkmgobfdidhgcmkakkdjdgamchgbij](https://chromewebstore.google.com/detail/superflow/jndkmgobfdidhgcmkakkdjdgamchgbij?utm_source=chatgpt.com)\n\nGitHub:\n[https://github.com/fivepairs67/superflow](https://github.com/fivepairs67/superflow?utm_source=chatgpt.com)\n\nIt’s still early, so honest feedback would be really helpful.", "subreddit": "r/SQL", "upvotes": 5, "date": "[PHONE]", "source": "https://www.reddit.com/r/SQL/comments/1s3dvmm/built_a_chrome_extension_to_visualize_sql_flow/"}
{"prompt": "Should I disable ONLY_FULL_GROUP_BY or leave it enabled?", "completion": "Should I disable ONLY_FULL_GROUP_BY or leave it enabled?\nWhen you Google \"ONLY\\_FULL\\_GROUP\\_BY,\" everyone always asks HOW to turn it off again ;)\n\nBut no one asks why it's enabled by default starting with version XY of MySQL, for example.\n\nDo you guys just turn it off too?\n\nI always liked it when I could write something like this WITHOUT getting flak for ONLY\\_FULL\\_GROUP\\_BY:\n\n`SELECT * FROM table GROUP BY name`\n\nor\n\n`SELECT name, age, town FROM table GROUP BY name`\n\n\nI have to write this now, even though it doesn't make sense:\n\n`SELECT name, age, town FROM table GROUP BY name, age, town`\n\nI know there's a workaround using ANY\\_VALUE(), but ultimately, I'm not comfortable with all this.\n\nSo should I just turn it off, or leave it enabled and adjust the queries accordingly?", "subreddit": "r/SQL", "upvotes": 5, "date": "[PHONE]", "source": "https://www.reddit.com/r/SQL/comments/1rtqnz4/should_i_disable_only_full_group_by_or_leave_it/"}
{"prompt": "Free Weekend SQL Coaching (Beginner → Advanced / Interview Preparation)", "completion": "Free Weekend SQL Coaching (Beginner → Advanced / Interview Preparation)\nHi everyone,\n\nI’m offering FREE online SQL coaching sessions every weekend for anyone who wants to learn SQL or improve their skills.\n\nThe sessions will start from beginner level and gradually move to advanced concepts, with the goal of making you confident and interview-ready.\n\nTopics we can cover include:\n\n• SQL basics (SELECT, WHERE, ORDER BY)\n\n• Aggregations and GROUP BY\n\n• JOINs and subqueries\n\n• Window functions\n\n• Query optimization\n\n• Real interview questions and practice problems\n\nSessions will be online via Zoom or Google Meet, and beginners are absolutely welcome.\n\nIf you're interested, comment below or send me a DM, and I’ll share more details about the weekend sessions.\n\nLooking forward to helping people learn SQL and prepare for interviews! 🚀", "subreddit": "r/SQL", "upvotes": 5, "date": "[PHONE]", "source": "https://www.reddit.com/r/SQL/comments/1rl5nc0/free_weekend_sql_coaching_beginner_advanced/"}
{"prompt": "Call Center Data Set", "completion": "Call Center Data Set\nHey I was wondering if anyone knew of any large practice dataset similar similar to Northwind but for Call Center type of data. So things like AHT, agents, teams, utilizations, customer sat, repeats etc? I know Kaggle has something but it seems to be just one table and I am looking for working on relational database among other things?", "subreddit": "r/SQL", "upvotes": 5, "date": "[PHONE]", "source": "https://www.reddit.com/r/SQL/comments/1tsgje2/call_center_data_set/"}
{"prompt": "i just found a game based on sql @ steam", "completion": "i just found a game based on sql @ steam\nmight get deleted but still posting\n\ngame link :-https://store.steampowered.com/app/3950130/Database\\_Detective\\_Minor\\_Crimes\\_Division/", "subreddit": "r/SQL", "upvotes": 5, "date": "[PHONE]", "source": "https://www.reddit.com/r/SQL/comments/1vv0muy/i_just_found_a_game_based_on_sql_steam/"}
{"prompt": "lakebase connection pooling", "completion": "lakebase connection pooling\nHave you figured out wht can the best way to handle connection pooling in Lakebase DB? I 'am seeing connection spikes with short lived rqsts and wondering what kind of setup others developers are using🤔\n\ni am building a service on top of lakebase and trying to make the connection relable before moving to prod.", "subreddit": "r/SQL", "upvotes": 5, "date": "[PHONE]", "source": "https://www.reddit.com/r/SQL/comments/1vrqqoa/lakebase_connection_pooling/"}
{"prompt": "Efficiently moving old rows between large PostgreSQL tables (Django)", "completion": "Efficiently moving old rows between large PostgreSQL tables (Django)\ni'm using Django/Postgres , and i have a table  `old_table` with millions of rows.i created another table with same schema  `new_table`. i want to move >4months old rows from the first one to the second and delete it from the old table,what is the **most efficient and safe way** to do this in PostgreSQL and ideally Django-friendly? I’m especially concerned about: performance (avoiding long locks / downtime and memory usage.\n\nAny best practices or real-world experience would be appreciated", "subreddit": "r/SQL", "upvotes": 5, "date": "[PHONE]", "source": "https://www.reddit.com/r/SQL/comments/1qdnzfd/efficiently_moving_old_rows_between_large/"}
{"prompt": "SQL idea for a registry or similar", "completion": "SQL idea for a registry or similar\nfirst, i work with healthcare data. i have a request to pull about 50 or more different types of data from a specific patient encounter. what they really need is a registry but our front end application team is way too busy to create it. I have never had a request like this and i am looking for solution ideas. i was thinking that i could create a few views for different inclusion criteria and then reference them in my stored procedure. any recommendations are appreciated", "subreddit": "r/SQL", "upvotes": 5, "date": "[PHONE]", "source": "https://www.reddit.com/r/SQL/comments/1qcw10r/sql_idea_for_a_registry_or_similar/"}
{"prompt": "DevScribe is now available on Windows after strong community demand (executable documentation for SQ and databases)", "completion": "DevScribe is now available on Windows after strong community demand (executable documentation for SQ and databases)\nBased on multiple requests from the community, I’ve released the **Windows version of** [**DevScribe**](https://devscribe.app/?utm_source=reddit&utm_medium=article&utm_campaign=sqlite) (Linux is also available).\n\n[DevScribe](https://devscribe.app/?utm_source=reddit&utm_medium=article&utm_campaign=developerindia) is a **local-first workspace** for working with databases and documentation together. You can now work with **MySQL, SQLite, PostgreSQL, MongoDB, and Elasticsearch** in a single desktop application.\n\nWhat this enables:\n\n* Write and **execute database queries** directly alongside documentation\n* **Visualize database schemas** next to queries and notes\n* Keep SQL examples, explanations, and results in one place\n* Avoid switching between DB tools and docs\n\nWith the latest release, DevScribe also supports **executable documentation**, meaning docs aren’t just text anymore:\n\n* Execute DB queries (MySQL, SQLite, PostgreSQL, MongoDB, Elasticsearch)\n* Run Java, JavaScript, TypeScript, and Shell scripts\n* Design HLD, Class, and ERD diagrams\n* Test REST APIs using a Postman-like interface\n\nEverything runs **locally**, with no server dependency or cloud sync.", "subreddit": "r/SQL", "upvotes": 5, "date": "[PHONE]", "source": "https://www.reddit.com/r/SQL/comments/1q3pf9v/devscribe_is_now_available_on_windows_after/"}
{"prompt": "How I Learned SQL in 4 Months Coming from a Non-Technical Background", "completion": "How I Learned SQL in 4 Months Coming from a Non-Technical Background\nSharing my insights from an article I wrote back in Nov, 2022 published in Medium as I thought it may be valuable to some here.\n\nFor some background, I got hired in a tech logistics company called Upaya as a business analyst after they raised $1.5m in Series A. Since the company was growing fast, they wanted proper dashboards & better reporting for all 4 of their verticals.\n\nThey gave me a chance to explore the role as a Data Analyst which I agreed on since I saw potential in that role(especially considering pre-AI days). I had a tight time frame to provide deliverables valuable to the company and that helped me get to something tangible.\n\nThe main part of my workflow was SQL as this was integral to the dashboards we were creating as well as conducting analysis & ad-hoc reports. Looking back, the main output was a proper dashboard system custom to requirements of different departments all coded back with SQL. This helped automate much of the reporting process that happened weekly & monthly at the company.\n\nI'm not at the company anymore but my ex-manager said their still using it and have built on top of it. I'm happy with that since the company has grown big and raised $14m (among biggest startup investments in a small country like Nepal).\n\nHere is my learning experience insights:\n\n1. Start with a real, high-stakes project\n\nI would argue this was the most important thing. It forced me to not meander around as I had accountability up to the CEO and the stakes were high considering the size of the company. It really forced me to be on my A-game and be away from a passive learning mindset into one where you focus on the important. I cannot stress this more!\n\n2. Jump in at the intermediate level\n\nReal-world work uses JOINs, sub-queries, etc. so start immediately with them. By doing this, you will end up covering the basics anyways (especially with A.I. nowadays it makes more sense)\n\n3. Apply the 80/20 rule to queries\n\n20% or so of queries are used more than 80% of the time in real projects.\n\nJOINS, UNION & UNION ALL, CASE WHEN, IF, GROUP BY, ROW\\_NUMBER, LAG/LEAD are major ones. It is important to give disproportionate attention to them.\n\nAgain, if you work on an actual project, this kind of disproportion of use becomes clearer.\n\n4. Seek immediate feedback\n\nAnother important point that may not be present especially when self-learning but effective. Tech team validated query accuracy while stakeholders judged usefulness of what I was building. Looking back if that feedback loop wasn't present, I think I would probably go around in circles in many unnecessary areas.\n\nResources used (all free)\n– Book: “Business Analytics for Managers” by Gert Laursen & Jesper Thorlund\n– Courses: Datacamp Intermediate SQL, Udacity SQL for Data Analysis\n– Reference: W3Schools snippets\n\nFun Fact: This article was shared by 5x NYT best-selling author Tim Ferriss too in his 5 Bullet Friday newsletter.", "subreddit": "r/SQL", "upvotes": 5, "date": "[PHONE]", "source": "https://www.reddit.com/r/SQL/comments/1quv6xy/how_i_learned_sql_in_4_months_coming_from_a/"}
{"prompt": "What job titles do you search for that requires you to use SQL and/or python? What job searching platforms do you use search for these jobs titles on", "completion": "What job titles do you search for that requires you to use SQL and/or python?  What job searching platforms do you use search for these jobs titles on\nSo far the job titles I searched for have been data analyst/data engineer/software engineer/business intelligence analsyst /power BI and so far the platforms I used to search for these titles has been indeed/LinkededIN and my states unemployment website.\n\nAny other suggestions?", "subreddit": "r/SQL", "upvotes": 5, "date": "[PHONE]", "source": "https://www.reddit.com/r/SQL/comments/1s8v5co/what_job_titles_do_you_search_for_that_requires/"}
{"prompt": "How to get better with SQL?", "completion": "How to get better with SQL?\nI work in Internal Audit and Data Analytics, and I would like to become more proficient with SQL. I use SQL every day, but after queries get past an intermediate level of difficulty, I have trouble conpleting my work. What resources did you use to become better at SQL?", "subreddit": "r/SQL", "upvotes": 5, "date": "[PHONE]", "source": "https://www.reddit.com/r/SQL/comments/1rvhcqt/how_to_get_better_with_sql/"}
{"prompt": "TRIGGER - Do BEFORE and AFTER have specific roles?", "completion": "TRIGGER - Do BEFORE and AFTER have specific roles?\nI'm a student and learnt SQL. It's actually very fun. I've completed a project in school, where I created a small trading system just using a database. So A and B have money and an inventory with items in it, and A can buy from or sell to B.\n\nI did that to practice TRIGGERS and CONSTRAINTS and it works, I can INSERT INTO a purchase or sale and all inventorys and money are updated.\n\nFor my system I created many TRIGGERS to have each one rather small. I've basically done the validation (enough money, enough items etc.) using BEFORE and all the changing things (changing money, items in inventory) using AFTER.\n\n**Question**\n\nIt worked perfectly for my project. But is that an actual meaning, convention or isn't there inherent thought for what BEFORE and AFTER should be used for besides the point in time when something should happen?", "subreddit": "r/SQL", "upvotes": 5, "date": "[PHONE]", "source": "https://www.reddit.com/r/SQL/comments/1rr3ta0/trigger_do_before_and_after_have_specific_roles/"}
{"prompt": "Dates, nulls, and strings are where cross-DB logic gets annoying fast", "completion": "Dates, nulls, and strings are where cross-DB logic gets annoying fast\nWhen queries move between engines, these three always seem to show up. The SQL looks fine, but the behavior suddenly isn’t.\n\nDates are usually the first thing that breaks. GETDATE() in SQL Server, NOW() in Postgres, SYSDATE in Oracle. That part is obvious enough. The more annoying part is date arithmetic.\n\nDATEADD(day, 1, mydate) works in SQL Server. Postgres wants interval syntax. Same logic, different syntax, and suddenly a query that looked harmless needs rewriting.\n\nNulls are another one. Most behavior is similar, but the small differences still bite. Null ordering is a good example. Postgres puts nulls last by default in ascending order. SQL Server puts them first. Same query, same data, different row order.\n\nStrings might be the sneakiest one. SQL Server is often case-insensitive because of collation settings. Postgres is case-sensitive by default. A filter that worked fine in SQL Server can quietly miss rows after a migration because the casing doesn’t match.\n\nNone of this is really “edge case” stuff either. It’s normal engine behavior, which is probably why it slips through reviews so easily.\n\nWhich one has wasted the most time for your team?", "subreddit": "r/SQL", "upvotes": 5, "date": "[PHONE]", "source": "https://www.reddit.com/r/SQL/comments/1thieb7/dates_nulls_and_strings_are_where_crossdb_logic/"}
{"prompt": "How to model recurring and installment transactions in a personal finance app?", "completion": "How to model recurring and installment transactions in a personal finance app?\nI'm building a personal finance app from scratch — Node backend with PostgreSQL, Nuxt on the frontend. The core features are already working: accounts, categories, transactions and transfers. Now I need to implement what I consider the most important feature for my own use as a user: recurring and installment transactions.\n\nThink of a monthly internet bill that repeats every month, or a purchase you split into 10 installments. That's exactly what I'm trying to model.\n\nAfter researching quite a bit, I came up with this approach:\n\nA separate `recurrences` table that stores the recurrence rule — type (fixed or installment), frequency, total installments when applicable, and whether it's still active. The existing transactions table would gain a single `recurrence_id` FK, null for one-time entries.\n\nRecords would be generated upfront — 12 months ahead for recurring, N records for installments, all linked by `recurrence_id`.\n\nMy main question is: does this schema make sense, or has anyone been down this road and found a better approach? Any criticism of the architecture is welcome.", "subreddit": "r/SQL", "upvotes": 5, "date": "[PHONE]", "source": "https://www.reddit.com/r/SQL/comments/1u1mfug/how_to_model_recurring_and_installment/"}
{"prompt": "To split tables or have more NULL values? - Weather's monthly vs annual data", "completion": "To split tables or have more NULL values? - Weather's monthly vs annual data\n\nFor a coursework, I must make ERD to 3NF and jsutify design choices which I must later use to make wireframes/app.\n\nI have got rainfall monthly data, rainfall annual data, and sunshine monthly data from [PHONE] years, 540 months. About 672 unique rows. There are 627 rows with NULL values for the abs\\_max\\_temp and abs\\_min\\_temp for rainfall monthly data. mean\\_sunshine hours again doesn't exist as annual data, and exists purely as monthly data (so 45 NULLS).\n\nI am thinking if I should create two tables by monthly and annual data instead of one Climate Observation table by adding another month nullable to first table (see below)? But the problem is that I would be repeating same titles twice, especially for rainfall and sunshine data?\n\ntime\\_period (time\\_id, year, month nullable)  ← stays the same\n\nannual\\_climate (observation\\_id, time\\_id FK, ...annual-specific columns)\n\nmonthly\\_climate (observation\\_id, time\\_id FK, ...monthly-specific columns)\n\nCan someone please help with what's the best approach please? Thank you!", "subreddit": "r/SQL", "upvotes": 5, "date": "[PHONE]", "source": "https://www.reddit.com/r/SQL/comments/1tzgu05/to_split_tables_or_have_more_null_values_weathers/"}
{"prompt": "Open-source ingestr v1: ingest data into your warehouse 12x faster", "completion": "Open-source ingestr v1: ingest data into your warehouse 12x faster\nHi folks, Burak here from Bruin. We have released ingestr as an open-source CLI tool 2 years ago here: [https://github.com/bruin-data/ingestr](https://github.com/bruin-data/ingestr)\n\nFor those that might not now: ingestr is a CLI tool to ingest data. It supports 100+ sources, 20+ destinations, takes care of schema detection, schema evolution, different materialization strategies like SCD2 out of the box. You can use the same CLI to copy a Postgres database to a destination, or pull data from Hubspot.\n\nIngestr, being a Python CLI, has been doing quite well but over time it started to show its age:\n\n* Performance: ingestr was not the fastest tool out there due to various reasons. We wanted to provide the fastest solution out there, but there were limitations out of our control.\n* Packaging: sharing a Python CLI tool across hundreds of different types of devices the users run it on ended up being quite a painful experience.\n* Reliability: ingestr relied on a stateful design due to a dependency, which brought all sorts of problems with it, especially around failed loads or corrupted state.\n* Upgrades: with all the dependencies we had, upgrades started to become a real struggle.\n\nDue to some of these issues, we have rebuilt ingestr v1 completely from scratch, in Go. We picked Go for a few reasons:\n\n* Go is fast. LIke, much faster than vanilla Python.\n* Go is a compiled language, meaning that we eliminate quite a lot of bugs ahead of time.\n* Go is great with agents: agents write perfect Go, which allows a small team like ours to move a lot faster than we normally could.\n* Go has great cross-compilation support: meaning that building self-contained binaries that runs on various operating systems becomes trivial with Go.\n\nThese advantages combined allowed us to have more features, and have a more solid foundation to build upon. On top of that, ingestr ended up being the fastest data ingestion tool out there based on our benchmarks. It is \\~3-5x faster than the closest alternative, up to 20 times faster than some others.\n\nIngestr v1 is live now on PyPi, and through our other installation methods: [https://github.com/bruin-data/ingestr](https://github.com/bruin-data/ingestr)\n\nI would love to hear your thoughts on what we can improve here. Thanks!", "subreddit": "r/SQL", "upvotes": 5, "date": "[PHONE]", "source": "https://www.reddit.com/r/SQL/comments/1tu0osy/opensource_ingestr_v1_ingest_data_into_your/"}
{"prompt": "Window Functions and their use cases in SQL", "completion": "Window Functions and their use cases in SQL\nHi, I wrote the second article about the window functions and their use cases with examples. Have a look at it: [https://medium.com/@sahilnayak2812/window-functions-and-their-use-cases-838812c8cebd](https://medium.com/@sahilnayak2812/window-functions-and-their-use-cases-838812c8cebd)", "subreddit": "r/SQL", "upvotes": 5, "date": "[PHONE]", "source": "https://www.reddit.com/r/SQL/comments/1vovlv6/window_functions_and_their_use_cases_in_sql/"}
{"prompt": "Bridge table where both sides are individually valid but can be incompatible per category — how do I enforce this?", "completion": "Bridge table where both sides are individually valid but can be incompatible per category — how do I enforce this?\nI have a classic many-to-many bridge table situation where both sides are **individually valid**, but the combination can still be **incompatible depending on category** — and I can't find a clean relational solution for it:\n\n    category (e.g. manufacturer+type combination)\n\n    item (a concrete, individual element — belongs to category_id)\n\n    component (catalog: possible \"part\" types — also belongs to category_id, because within a given category the physical properties of a component differ from another category's, even if the name/code happens to match)\n\n    item_component (bridge table: item_id <-> component_id)Simplified:\n    category (e.g. manufacturer+type combination)\n\n    item (a concrete, individual element — belongs to category_id)\n\n    component (catalog: possible \"part\" types — also belongs to category_id, because within a given category the physical properties of a component differ from another category's, even if the name/code happens to match)\n\n    item_component (bridge table: item_id <-> component_id)\n\n\nThe `category_id` **inherently determines** which `component`s can even be compatible with a given `item` — a component from a different category is **structurally incompatible**, not just \"a different version\" or \"a less ideal choice.\" So the component's existence/dimensions are inherently dependent on the category — it's not a standalone, category-independent thing that just happens to have a category \"tag\" on it.\n\n**The problem:** the `item_component` bridge table connects both sides with a simple FK each (`item_id -> item`, `component_id -> component`). The database only guarantees that both IDs exist *somewhere* in their respective tables — but **nothing checks** whether the `item` and `component` are of a **compatible category**. So a row can easily be inserted where an `item` of one category gets paired with a `component` from an **incompatible, different category** — the database happily accepts this, even though it's a physically/logically invalid combination.\n\nIs it possible that I'm approaching this entirely wrong from the start, and instead of patching this bridge table, I should be thinking in terms of a completely different table structure?", "subreddit": "r/SQL", "upvotes": 5, "date": "[PHONE]", "source": "https://www.reddit.com/r/SQL/comments/1vfcb1t/bridge_table_where_both_sides_are_individually/"}
{"prompt": "How should a total beginner structure their SQL roadmap", "completion": "How should a total beginner structure their SQL roadmap\nI just finished learning simple queries and filtering logic. My next step is getting comfortable with joining tables and aggregating data. However I keep hearing about advanced concepts that sound intimidating right now. I am wondering if I should stick to this step by step path or jump into building a project instead.", "subreddit": "r/SQL", "upvotes": 5, "date": "[PHONE]", "source": "https://www.reddit.com/r/SQL/comments/1ws5f5t/how_should_a_total_beginner_structure_their_sql/"}
{"prompt": "I built an app that uses Jev to classify your entire query workload and tell you which queries to EXPLAIN ANALYZE first", "completion": "I built an app that uses Jev to classify your entire query workload and tell you which queries to EXPLAIN ANALYZE first\nI posted here last month about RDST, the free desktop app that runs the slow query to EXPLAIN to index recommendation loop. The biggest change since then is what happens before EXPLAIN. When a database has thousands of distinct query shapes, you can't EXPLAIN ANALYZE all of them, and sorting queries by their performance doesn't always tell you which ones are actually badly written.\n\n\nRDST now answers that with Jev, a small classification model from TypeSafe that answers fixed multiple-choice questions about a query in a fraction of a second. Every query shape it discovers gets classified from its SQL and the schema, without executing anything, on five structural questions:\n\n* missing index - a filtered, joined or sorted column with nothing indexed behind it\n* index bypassed - a filtered column wrapped in a function or cast, so the index you have goes unused\n* join growth - the join shape multiplies rows\n* repeated work - a subquery that runs once per outer row\n* broad work - a sort, group or scan over a large share of a table\n\nFrom there you take the full list of queries, filter them by these structural issues, and run our deep analysis on the ones that actually make sense. Deep analysis runs EXPLAIN ANALYZE with real parameter values, tests candidate indexes with hypopg, scores the measured plan, and gives you AI recommendations on what to change.\n\n\nOne of our queries, in the video above, counts each customer's orders in a correlated subquery filtered on customers.signup\\_date. Jev flagged it High: missing index and repeated work, and it's right, nothing indexes signup\\_date. Deep analysis then scored it 92 out of 100, because at only 5,000 rows the scan takes under a millisecond and the subquery already hits idx\\_orders\\_customer. Jev alerts you to potential issues, and deep analysis helps you fix the queries that are actually broken.\n\nSomeone in last month's thread said that the optimizer would rightly ignore one of the indexes RDST suggested, and this is our answer to that feedback: Jev classification on every single query.\nClassification is free for up to 13,000 query shapes, after that let me know and i can adjust to give even more.  Just didn't want to make it infinite and have people abuse the system.\n\n\nFull disclosure, I work for Readyset, which is a caching layer for Postgres and MySQL. I built RDST to help with slow query indexing and analysis, and picking which query to open first was the step I kept doing by hand. Free and open source under MIT license, works with both PG and MYSQL, runs locally, stores locally, and is fundamentally read-only throughout.  Our RDST app will never apply the index or write anything to your database, nor store / send any PII.\n\nFully privacy details here: [https://readyset.io/docs/readyset-ai/rdst/desktop/privacy](https://readyset.io/docs/readyset-ai/rdst/desktop/privacy)\n\nI would really really appreciate some feedback, particularly:\n\n* Do those five questions cover the structural problems you actually hit?\n* Does the priority ordering match your own gut ranking of your slow queries?\n* Once EXPLAIN has measured a query, should the classification stay visible or get out of the way?\n\nInstructions & Github:\n[https://readyset.io/downloads](https://readyset.io/downloads)\n[https://github.com/readysettech/rdst](https://github.com/readysettech/rdst)", "subreddit": "r/SQL", "upvotes": 5, "date": "[PHONE]", "source": "https://www.reddit.com/r/SQL/comments/1woc8kv/i_built_an_app_that_uses_jev_to_classify_your/"}
{"prompt": "Practicing multi-table joins and losing track of which columns come from where — any tips for staying organized?", "completion": "Practicing multi-table joins and losing track of which columns come from where — any tips for staying organized?\nI understand the basic JOIN syntax, but keeping track of table relationships, aliases, and column names gets confusing as the query becomes longer.", "subreddit": "r/SQL", "upvotes": 5, "date": "[PHONE]", "source": "https://www.reddit.com/r/SQL/comments/1wnfsia/practicing_multitable_joins_and_losing_track_of/"}
{"prompt": "The Postgres job-claim query that silently claims the same job twice under READ COMMITTED", "completion": "The Postgres job-claim query that silently claims the same job twice under READ COMMITTED\nA common pattern to claim background jobs in PostgreSQL is executing a single statement like:\n\n\\`\\`\\`sql\nUPDATE jobs\nSET status = 'processing', worker\\_id = $1\nWHERE id = (\nSELECT id FROM jobs\nWHERE status = 'pending'\nORDER BY created\\_at ASC\nLIMIT 1\n)\nRETURNING \\*;\n\nBecause it's a single statement, it looks atomic on paper. But under the default **READ COMMITTED** isolation level, it can silently allow two concurrent workers to claim the exact same row.\n\nWhat actually happens:\n\n1. **Worker A** and **Worker B** execute the query at the exact same moment. Both subqueries snapshot the same pending job row (say ⁠id = 42⁠).\n\n2. **Worker A** acquires the row lock first and updates its status.\n\n3. **Worker B** waits on the lock. Once Worker A commits and releases the lock, Worker B evaluates the outer row.\n\n4. Because the subquery snapshot is **not re-evaluated**, Worker B sees the updated row, rechecks the outer predicate, and silently overwrites/re-claims ⁠id = 42⁠.\n\nNo lock wait timeout, no deadlock, no serialization error—just silent duplicate job execution in production.\n\nI wrote an in-depth breakdown mapping the lock timeline, why the subquery snapshot doesn't re-run, and why ⁠FOR UPDATE SKIP LOCKED⁠ inside a CTE is the actual safe pattern:\n\n👉 **Full writeup:** https://vishwam.hashnode.dev/the-postgres-job-claim-query-that-silently-claims-the-same-job-twice\n\nWould love to hear how folks here handle Postgres-backed queues or if anyone has run into this specific subquery recheck behavior before!", "subreddit": "r/SQL", "upvotes": 5, "date": "[PHONE]", "source": "https://www.reddit.com/r/SQL/comments/1wkm9aq/the_postgres_jobclaim_query_that_silently_claims/"}
{"prompt": "'FOR SYSTEM_TIME ALL ORDER BY valid_from' takes way too long!", "completion": "'FOR SYSTEM_TIME ALL ORDER BY valid_from' takes way too long!\nI have some LINQ code that looks like this:\n\n`await context.Records`\n\n`.TemporalAll()`\n\n`.OrderByDescending(e => EF.Property<DateTime>(e, \"valid_from\"))`\n\n`.Take(200)`\n\n`.ToListAsync();`\n\n\nThis times out. 'Records' has thousands of rows, and the history table has millions, but there's an index on valid\\_from on both, so this shouldn't be timing out.\n\nThe SQL being generated looks like this:\n\n`SELECT TOP(200) *`\n\n`FROM [records] FOR SYSTEM_TIME ALL`\n\n`ORDER BY valid_from DESC`\n\n\nExecuted in SSMS, it takes about a minute and a half to get me 200 rows. Which is unacceptable.\n\n\nThis, however, executes instantly and gets me the same results:\n\n`select top(200) * from`\n\n`(select top(200) * from records order by valid_from DESC`\n\n`UNION`\n\n`select top(200)* from records_history order by valid_from DESC`\n\n`) as r`\n\n `order by r.valid_from DESC`\n\n\nHow can I make the first query go fast?\n\nExecution plan analysis shows that with the first query, we're doing a Clustered Index Scan on records (0% cost), Table Scan on records\\_history (8% cost), then concatenating and Top N sorting (92% cost).\n\n\nFor the second, we're doing a Key Lookup for records (49% cost), RID lookup on records\\_history, then concatenating and doing a sort (1% cost).", "subreddit": "r/SQL", "upvotes": 4, "date": "[PHONE]", "source": "https://www.reddit.com/r/SQL/comments/1q7gy3o/for_system_time_all_order_by_valid_from_takes_way/"}
{"prompt": "Learn Databricks 101 through interactive visualizations - free", "completion": "Learn Databricks 101 through interactive visualizations - free\nI made 4 interactive visualizations that explain the core Databricks concepts. You can click through each one - google account needed -\n\n1. Lakehouse Architecture - [https://gemini.google.com/share/1489bcb45475](https://gemini.google.com/share/1489bcb45475)\n2. Delta Lake Internals - [https://gemini.google.com/share/2590077f9501](https://gemini.google.com/share/2590077f9501)\n3. Medallion Architecture - [https://gemini.google.com/share/ed3d429f3174](https://gemini.google.com/share/ed3d429f3174)\n4. Auto Loader - [https://gemini.google.com/share/5422dedb13e0](https://gemini.google.com/share/5422dedb13e0)\n\nI cover all four of these (plus Unity Catalog, PySpark vs SQL) in a 20 minute Databricks 101 with live demos on the Free Edition: [https://youtu.be/SelEvwHQQ2Y](https://youtu.be/SelEvwHQQ2Y)", "subreddit": "r/SQL", "upvotes": 4, "date": "[PHONE]", "source": "https://www.reddit.com/r/SQL/comments/1r0ltar/learn_databricks_101_through_interactive/"}
{"prompt": "DBeaver Mac: Missing \"Image\" Transformation for BYTEA column in Grid View", "completion": "DBeaver Mac: Missing \"Image\" Transformation for BYTEA column in Grid View\nIn my data grid, the column `image_png` only shows the text string `PNG IHDR...` instead of the image. Interestingly, the Value Panel on the right renders the PNG perfectly.\n\nHowever, when I try to force the preview via View/Format -> Set column transform, the \"Image\" option is missing,I only see \"Default\", \"Geometry\", and \"UUID\".\n\n**What I've tried so far:**\n\n1. Checked Preferences -> Result Sets -> Table: The toggle \"Show images in grid\" seems to be missing?\n2. Changed Binary data formatter from \"String\" to \"Binary/Hex\" in Preferences.\n3. Increased Max LOB length to 1,000,000 bytes.\n4. Refreshed the connection and data multiple times.\n\nIm certain it's a pretty easy fix - but not for me..\nThanks in advance!! :)", "subreddit": "r/SQL", "upvotes": 4, "date": "[PHONE]", "source": "https://www.reddit.com/r/SQL/comments/1ri27wo/dbeaver_mac_missing_image_transformation_for/"}
{"prompt": "Tool for schema diffing in a hybrid SQL Server / Postgres environment?", "completion": "Tool for schema diffing in a hybrid SQL Server / Postgres environment?\nHey guys,\n\nOur stack is getting a bit messy. Most of our legacy stuff is on **SQL Server**, but some of our newer microservices are running on **Postgres**. Managing schema changes between Dev and Staging is becoming a nightmare because I'm constantly switching between different tools.\n\nI need to find a way to audit schema drift and generate `ALTER` scripts without paying for two separate enterprise licenses. Security is also a big thing for us—it has to be an **offline/local tool** (no cloud-based DB connections allowed).\n\nIs there any lightweight, cross-platform tool that handles both? I'm tired of running a Windows VM just to do a quick diff on a SQL Server schema when I'm working on my Mac/Linux machine.\n\nWhat’s your workflow for handling migrations when you're stuck between two different DB engines?", "subreddit": "r/SQL", "upvotes": 4, "date": "[PHONE]", "source": "https://www.reddit.com/r/SQL/comments/1sy7bqj/tool_for_schema_diffing_in_a_hybrid_sql_server/"}
{"prompt": "how to create data sample / csv from dmp and sql", "completion": "how to create data sample / csv from dmp and sql\ni’m sorry but i’m at my wits end, i’ve spent literal nonstop days worth of hours trying to figure out how to extract usable data from a folder of SQL files and 1 DMP file, and no matter what i do i can’t seem to get anything usable. Between figuring out MySql and SQL developer, i’ve been doing everything to try to import the dmp file to try to examine it, but no matter what i do i can’t get it to import properly, be it because of what feels like all the errors, permissions, listener configurations, granted rights, or import wizard managing to (finally) recognise the tables, just for the task to fail right at the end preventing me from importing anything before i can get anything usable.\n\nThen there r the many SQL files along with the DMP file that based on my understanding, are the commands for the table generation etc to create the skeletons of the data structures captured in the dmp file.\n\ni just don’t know if i am missing something completely obvious here and whether there is a straightforward method of extracting the data from the DMP file combined with the SQL files that i’m just not seeing.\n\ni’m so desperate i was even looking at SQLite conversions from sql because i have some very minor experience in it, but even then, that isn’t straightforward either\n\nfor some background, i was supplied with a password (not a user name, but i have a log file of the dmp and sql files extraction if that is helpful in any way). i can’t share snapshots, because it is sensitive information, but i feel like this must be a common practice of sharing a sample of data, so maybe there is something straightforward about this that i just don’t know ? Any advice/guidance or help would be so very much appreciated 🙏", "subreddit": "r/SQL", "upvotes": 4, "date": "[PHONE]", "source": "https://www.reddit.com/r/SQL/comments/1sg8php/how_to_create_data_sample_csv_from_dmp_and_sql/"}
{"prompt": "Forward filling of missing values through variables in MySQL", "completion": "Forward filling of missing values through variables in MySQL\nHey folks!\n\nWhile practicing MySQL last year, I came across the forward filling problem whereby you've to replace each NULL value in a column by the latest non-NULL value in that column.\n\nFor instance, a table `ffill` is as follows:\n\n[Table is 'ffill' with 6 records](\n\nThe expected output is as below:\n\nAs we can see, the `NULL` values in `dept` column are forward filled. Here is the MySQL query I wrote back then to yield the output table above:\n\nMy question is, are there caveats of forward filling like this? What might they be? Will this way always work across the DBMSes? What would be the implications of this approach on large data sets?", "subreddit": "r/SQL", "upvotes": 4, "date": "[PHONE]", "source": "https://www.reddit.com/r/SQL/comments/1t47tvk/forward_filling_of_missing_values_through/"}
{"prompt": "DBeaver for a beginner like me - getting rid of Workbench", "completion": "DBeaver for a beginner like me - getting rid of Workbench\nhi all!\n\n\nAs a beginner in working with relational DBMS, i started with mysql.\n\nHowever, after reading some more, i came to find out that Workbench - the go-to tool for mysql editing for many people - is no longer properly actively maintained (updated) for quite some time now...\n\nAlso, Workbench isnt available for Linux Mint (my fav distro).\n\nTo shoot two birds with one stone, i decided to look for an alternative - and lo and behold, i found DBeaver.\n\nAs i am sure you guys already know, Workbench comes in 2 \"flavours\" - a minimal 200 MB installation (gui client only) and a 500+ mb installation (server/ connector client with gui etc).\n\nThe problem faced by a beginner like me - on a fresh pc (win11), installing DBeaver and attempting to connect to a mysql database WITHOUT having any trace of Workbench installed...is impossible (it returns connection errors....of course, there is nothing to connect to...)!\n\nAfter lots of trial and failure in setting up a msql driver to connect to a DB, reading, and youtube-ing, i came to find out that DBeaver lacks a critical component - the db engine, a server.\n\nThis is confirmed, seeing how all tutorials - even those this year - have a complete Oracle Mysql Workbench installation prior to installing and running DBeaver.\n\n\nDIRECT QUESTION - is there a way to set up (on localhost...) a db engine so i can create a new mysql connection and use mysql dabatases ***WITHOUT*** anything related to Workbench from Oracle installed on my pc ...? or are we stuck with Workbench forever ?\n\ni give up, after tones of trying ...\n\nIF there is, please tell me directly...thanks a lot!", "subreddit": "r/SQL", "upvotes": 4, "date": "[PHONE]", "source": "https://www.reddit.com/r/SQL/comments/1u97vxk/dbeaver_for_a_beginner_like_me_getting_rid_of/"}
{"prompt": "Using DateAdd for timestamps", "completion": "Using DateAdd for timestamps\nI am making updates to some older reports and come across this line (or similar) often:\n\nDateAdd(hh, 0, GetDate())\n\nWhy do you do that? Is there a legitimate reason why you couldn’t just write GetDate()?", "subreddit": "r/SQL", "upvotes": 4, "date": "[PHONE]", "source": "https://www.reddit.com/r/SQL/comments/1wpz3m0/using_dateadd_for_timestamps/"}
{"prompt": "Writing SQL from scratch vs editing old queries?", "completion": "Writing SQL from scratch vs editing old queries?\nHi everyone!\n\nI notice I’m way more comfortable modifying an existing query than writing one from a blank screen. Starting from scratch always feels slower.\n\nDo you usually build queries from scratch, or copy and adapt older ones? And did writing from scratch get easier over time, or do you still reuse patterns?", "subreddit": "r/SQL", "upvotes": 4, "date": "[PHONE]", "source": "https://www.reddit.com/r/SQL/comments/1qkpzy6/writing_sql_from_scratch_vs_editing_old_queries/"}
{"prompt": "Please suggest some good newsletter covering SQL & DB management", "completion": "Please suggest some good newsletter covering SQL & DB management\nLooking for some suggestions of good newsletters or blogs in this area which I can use to get back in touch with SQL. There were a few Medium pages & email newsletters which used to share problems to work on to level up our SQL skills which I was subscribed to a few years ago & also had tips on best practices. These newsletters played an important role in my learning process. Now that I want to brush up my knowledge as I have been out of touch for a long time , I have forgotten their names & was wondering if the subreddit could suggest me some good newsletters/blogs.", "subreddit": "r/SQL", "upvotes": 4, "date": "[PHONE]", "source": "https://www.reddit.com/r/SQL/comments/1q5pdlk/please_suggest_some_good_newsletter_covering_sql/"}
{"prompt": "Improving merge statement with an index", "completion": "Improving merge statement with an index\nHey, I have a store table with 3 million rows that gets merged with a staging table containing 2 million rows every day. The `ON` clause of the `MERGE` statement consists of 5 columns, and the table itself has 50 columns in total.\n\nAbout 99% of the staging table rows match based on the `ON` clause, but only a few rows are actually updated. Currently, the process takes 8 minutes, and I want to improve the performance.\n\nI created an index on the 5 columns used in the `ON` clause, but it still takes 8 minutes. Is this expected because almost all rows from the staging table are matched, and therefore the optimizer most likely performs a table scan instead of using the index?", "subreddit": "r/SQL", "upvotes": 4, "date": "[PHONE]", "source": "https://www.reddit.com/r/SQL/comments/1r8brzw/improving_merge_statement_with_an_index/"}
{"prompt": "a question for a career path.", "completion": "a question for a career path.\nHello everybody. With this post i hope to reach some people that have realy good knowlede about the SQL World and maybe a similar path as mine. I hope yall can help me out because im a little bit stuck right now.\n\nSo lets start with the following.\n\nI am currently 24 Years old and i finished an IT College with specialication on IT Security, although we had every Coding Language etc… at school. I quickly fell in love with the Data World and SQL. It was my best subject and i knew i wanted to work with it. Now i had a job for the past 3 Years working as an Power BI Developer mainly creating dashboards and reports as requested from our customers. Sadly the people around were pretty corrupt snd the vibe was just totaly off so i decided to quit. Now i am thinking what i could do to improve my knowledge to get even further into the Data World.\n\nRight now i am thinking to do a course to be a „Microsoft Power BI Analyst“ Which i personaly think fits quite well into my profile so far. I was also thinking to learn Python to maybe get a little bit into Data Science. I know That Power Bi and Data Science isnt realy the same thing at all so i am a little bit stuck on what to learn.\n\nI also heard that Java or Javascript could be a good language to learn next to Sql.\n\nWhat do you guys think? Any suggestion on what goes realy good with SQL and Power Bi Knowledge to get a super good future proof career profile?\n\nI appreciate all the answers and sorry for the long text \\^\\^\n\nHope you are all doing well and god bless\n\nKind Regards", "subreddit": "r/SQL", "upvotes": 4, "date": "[PHONE]", "source": "https://www.reddit.com/r/SQL/comments/1rnsnre/a_question_for_a_career_path/"}
{"prompt": "Portfolio Project Review", "completion": "Portfolio Project Review\nHello, I have finished a credit risk analysis for my portfolio project. Need honest feedback suggestion to improve. Please click on the [Project](https://github.com/Shahimti/Credit-Risk-Portfolio-Analysis-Sql) to see the full github repo and share your feedback if possible. Thanks.", "subreddit": "r/SQL", "upvotes": 4, "date": "[PHONE]", "source": "https://www.reddit.com/r/SQL/comments/1rlvdqw/portfolio_project_review/"}
{"prompt": "Old question, but no concrete answers can I find. Weighted Average", "completion": "Old question, but no concrete answers can I find.  Weighted Average\nThis is for Loan Interest\n\nI know the basics; (Balance\\*Interest Rate)/Balance = foo\nBut they want the average across all loans.\nI've got (SUM(\\[Balance\\] \\* \\[IntRate\\])/SUM(\\[Balance\\]) which gives me a reasonable number result.  But I don't know if it's accurate. It's this part that has me questioning myself:\n(SUM(\\[Balance\\] \\* \\[IntRate\\]) - is \\*that\\* the right way to get the value? (That I divide by SUM(\\[Balance\\])\nIt seems like it's too simple so I fear I'm missing something.  Any input or insights appreciated.", "subreddit": "r/SQL", "upvotes": 4, "date": "[PHONE]", "source": "https://www.reddit.com/r/SQL/comments/1rkqo93/old_question_but_no_concrete_answers_can_i_find/"}
{"prompt": "Why does SSMS22 copy/paste results weird?", "completion": "Why does SSMS22 copy/paste results weird?\nI noticed copying grid results into excel using ssms22 and selecting non-continuous cells by holding ctrl will paste them all in a single header. Why on earth is this the case and can it be changed? I can't find anything in the documentation. It goes from this:\n\nand then pastes as this:\n\ni am befuddled by how dumb this is but I guess my specific use case thinks this sucks but maybe its intended idk. if theres a way to change it please help!", "subreddit": "r/SQL", "upvotes": 4, "date": "[PHONE]", "source": "https://www.reddit.com/r/SQL/comments/1rknja3/why_does_ssms22_copypaste_results_weird/"}
{"prompt": "Removing duplicate records from CASE buckets", "completion": "Removing duplicate records from CASE buckets\nI have the following code that is technically bucketing my data correctly, but it's not doing what I intended.\n\nThe query is counting the `UserId__c` every time it falls into a bucket, but I want it to only capture the FIRST bucket it falls into.\n\n`SELECT COUNT( DISTINCT UserId__c),`\n  `CASE`\n`WHEN DATEDIFF('day', LoginTime__c, NOW()) BETWEEN 0 AND 7 THEN '0 - 7 Days'`\n`WHEN DATEDIFF('day', LoginTime__c, NOW()) BETWEEN 8 AND 14 THEN '08 - 14 Days'`\n`WHEN DATEDIFF('day', LoginTime__c, NOW()) BETWEEN 15 AND 30 THEN '15 - 30 Days'`\n`WHEN DATEDIFF('day', LoginTime__c, NOW()) > 30 THEN '31+ Days'`\n  `END AS Bucket`\n`FROM LoginHistory__dlm l`\n`INNER JOIN User_Temp__dlm u`\n`ON l.UserId__c = u.user_ID__c`\n`GROUP BY Bucket`\n`ORDER BY Bucket asc`\n\nI'm getting the following results:\n\n|Bucket|Count of Rows|\n|:-|:-|\n|0 - 7 Days|1,229|\n|08 - 14 Days|1,337|\n|15 - 30 Days|1,246|\n|31+ Days|1,889|\n\nWhen I remove the buckets, the true count of `DISTINCT UserId__c` is 1,912 - this total is correct.\n\n\nHow do I stop the query from counting every instance of `UserId__c`?\n\n\n*This is in Salesforce CRMA, so it's technically Data 360 SQL (if that matters).*", "subreddit": "r/SQL", "upvotes": 4, "date": "[PHONE]", "source": "https://www.reddit.com/r/SQL/comments/1sut7oa/removing_duplicate_records_from_case_buckets/"}
{"prompt": "We built federated SQL over MySQL, Postgres, and S3 - one query, multiple sources", "completion": "We built federated SQL over MySQL, Postgres, and S3 - one query, multiple sources\n\n\nBeen experimenting with running SQL across multiple sources without moving data around first.\n\nUnder the hood it's DuckDB, used as a read layer to query:\n\n\\- MySQL / PostgreSQL\n\n\\- local files (CSV, JSON, Parquet)\n\n\\- S3-compatible storage\n\nThe idea is simple: instead of ETL or connectors, just attach sources and query them together.\n\nExample:\n\n\\`\\`\\`\n\nSELECT\n\n  o.order\\_id,\n\n  o.amount,\n\n  p.category\n\nFROM postgres.public.orders o\n\nJOIN read\\_parquet('s3://bucket/products.parquet') p\n\n  ON o.product\\_id = [p.id](http://p.id);\n\n\\`\\`\\`\n\nWorks well for:\n\n\\- validation before/after migrations\n\n\\- comparing datasets across systems\n\n\\- quick analysis without setting up pipelines\n\nNot a fit for:\n\\- continuous CDC (this is a read layer)\n\\- heavy transactional workloads\n\nFull disclosure: this is part of DBConvert Streams, a self-hosted tool. The IDE (including federated queries) is free, streaming/CDC is paid.\n\nMore details here:\n\n[https://streams.dbconvert.com/cross-database-sql/](https://streams.dbconvert.com/cross-database-sql/)\n\nHappy to answer questions about DuckDB integration, type handling, or edge cases.", "subreddit": "r/SQL", "upvotes": 4, "date": "[PHONE]", "source": "https://www.reddit.com/r/SQL/comments/1smm1ve/we_built_federated_sql_over_mysql_postgres_and_s3/"}
{"prompt": "How I model the identity layer for multi-tenant RBAC (before touching roles and permissions)", "completion": "How I model the identity layer for multi-tenant RBAC (before touching roles and permissions)\nRBAC is a well-known concept that most software engineers have encountered. For me, it is an interesting topic worth sharing, especially in the context of a multi-tenant system.\n\n# Part 1: Identity Foundation\n\n# Behavior Description\n\nAssume we are building a KPI management platform. Multiple companies can create accounts (tenants) and let their employees access the platform.\n\n* A user can be assigned to one or several roles. Their permissions are the sum of those roles’ permissions.\n* A user cannot access features outside their permissions. Even if they know the API specs and bypass the UI, they will still be blocked at the API layer.\n* Admins can change a user’s roles or a role’s permissions at any time. The only inconvenience is that the affected user needs to log out and log back in for the changes to take effect.\n\nSounds straightforward, right? Let’s look at what happens under the hood.\n\n# Deriving the Data Model from Use Cases\n\nBefore implementing, I take time to think about what the system needs to do and what data structures are required to support those use cases.\n\nThe first thing we hear in the spec is “multiple tenants.” A system that serves multiple companies and their users. That gives us at least two objects to start with: `tenants` and `users`.\n\nhttps://reddit.com/link/1shjqpg/video/dcdljxzbkcug1/player\n\n>\n\n# Defining the Relationship Between Tenants and Users\n\nNow we have the foundation, but the relationship between `tenants` and `users` is not yet defined. To define it, we need to find the right constraint. There are two cases:\n\n* **Case 1:** One tenant can have many users. One user must use a unique email per tenant.\n* **Case 2:** One tenant can have many users. One user can use the same email across different tenants.\n\nConsider this scenario: you are a contractor working for two different companies that both use this platform. If we go with Case 1, the best you can do is maintain two separate emails for two separate tenants on the same system. That is a real inconvenience.\n\nNotice I used the word **person** instead of **user** here. Technically, every tenant is independent. There is no good reason to force a person to use a different email just to become a user of another tenant.\n\n**Case 2 is the preferred design.**\n\n# Tenant Identification at Login\n\nThis raises a natural question: if a user can log in with the same email across multiple tenants, how do we know which tenant they belong to?\n\nThe answer is that when a user logs in, we need to identify the tenant. There are a few approaches:\n\n* Ask the user to type a tenant code in the login form. Bad idea.\n* Provide a typeahead field to help the user find their tenant code. Still a bad idea.\n* Give each tenant a subdomain or sub-path, such as [`tenant1.ourplatform.com`](http://tenant1.ourplatform.com) or `ourplatform.com/tenant1`. This is the widely accepted approach, especially the subdomain variant. The only tradeoff is that instead of a standard SSL certificate, you need a wildcard SSL certificate.\n\n# The Identity Table\n\nAnother natural question follows: if users share an email across tenants, can they also share a password?\n\nNo. Password policies can differ per tenant, so sharing passwords across tenants is not acceptable. This leads us to a third object: the `identities` table. An identity represents a user’s membership in a specific tenant, containing tenant’s specific info", "subreddit": "r/SQL", "upvotes": 4, "date": "[PHONE]", "source": "https://www.reddit.com/r/SQL/comments/1shjqpg/how_i_model_the_identity_layer_for_multitenant/"}
{"prompt": "Is an 800-hour data analytics program worth it for practical SQL/BI skills, or is hands-on learning better?", "completion": "Is an 800-hour data analytics program worth it for practical SQL/BI skills, or is hands-on learning better?\nHi,\n\nI’m currently at a beginner level with SQL and trying to decide on the most effective way to build practical data skills\n\nI’m considering an open university program (\\~800 hours total) that covers:\n\n\t•\tData analytics fundamentals\n\n\t•\tSQL & databases (including a project)\n\n\t•\tProgramming for data work\n\n\t•\tBI tools (data cleaning, modeling, reporting)\n\n\t•\tData visualization / information design\n\n\t•\tWorking with external and social data sources\n\nMy short-term goal is to apply SQL and data skills in my current role in igaming (VIP/CRM/retention analysis). Longterm, I’m considering moving deeper into data-related roles, but that path isn’t fully defined yet\n\nMy main concern is efficiency:\n\n•\tHow practical are programs like this in terms of real world skills?\n\n•\tWould 800 hours in a structured academic setting be worth it, or is a more hands-on/self-driven approach (projects, real datasets, SQL + BI tools) typically more effective?\n\nWhat are your thoughts on this?", "subreddit": "r/SQL", "upvotes": 4, "date": "[PHONE]", "source": "https://www.reddit.com/r/SQL/comments/1senahx/is_an_800hour_data_analytics_program_worth_it_for/"}
{"prompt": "Building a SQL database in Rust: why I replaced Ident(String) with spans", "completion": "Building a SQL database in Rust: why I replaced Ident(String) with spans\nI'm building a SQL database engine from scratch in Rust, and while working on the lexer I ended up changing a couple of design decisions that taught me more than the lexer itself.\n\nMy first implementation stored the input as a `Vec<char>` and identifiers as:\n\n    Ident(String)\n\n\nwhich felt natural at the time.\n\nAs the project grew, I started questioning how much data I was actually copying around.\n\nThe source SQL already contains every identifier, so storing another `String` inside every identifier token felt wasteful.\n\nI eventually switched to:\n\n    Ident\n\n\nplus span information:\n\n    Span {\n        start,\n        end,\n        line,\n        column,\n    }\n\n\nNow tokens only store what they are and where they came from.\n\nWhen the parser needs the actual identifier text, it can recover it directly from the original source using the span.\n\nI also moved away from `Vec<char>` and redesigned the lexer around a borrowed `&str`.\n\nThe result is:\n\n* No duplicated identifier strings\n* Fewer allocations\n* No copied input buffer\n* Better source mapping for diagnostics\n* Simpler token representation\n\nCurrent output looks like:\n\n    Select @ line 1, col 1, bytes 0..6\n    Ident @ line 1, col 8, bytes 7..11\n    Comma @ line 1, col 12, bytes 11..12\n    ...\n\n\nFor people who have built lexers, parsers, compilers, or databases before:\n\nWould you keep this span-based approach all the way through parsing and AST generation, or would you intern identifiers at some stage?\n\nI'm curious how others approached this problem.", "subreddit": "r/SQL", "upvotes": 4, "date": "[PHONE]", "source": "https://www.reddit.com/r/SQL/comments/1tsqgk5/building_a_sql_database_in_rust_why_i_replaced/"}
{"prompt": "Having issues inserting data into MySQL database from my website", "completion": "Having issues inserting data into MySQL database from my website\nThis problem really confounds me. So I have a Linode Shared Server with my website on it. My website has a SQL database which allows people to upload data into it using a form.\n\nIf I go to my website and try to upload data using the form, it works fine. But if I do it from outside of my wi-fi, it refuses to insert anything. I tried this using my phone and it works when connected to wi-fi but it doesn't when it is not.\n\nReading from the database works across the spectrum.\n\nSo I assume somehow linode or the sql database are filtering out anything that is not my IP but I never white listed my IP in the first place so I am very confused.\n\nNote: When I used the old Ubuntu 12 server on Linode, this process worked fine. I migrated everything to a newer server with Ubuntu 24 and suddenly this has been happening.", "subreddit": "r/SQL", "upvotes": 4, "date": "[PHONE]", "source": "https://www.reddit.com/r/SQL/comments/1tg5y7e/having_issues_inserting_data_into_mysql_database/"}
{"prompt": "PgStudio - PostgreSQL VS Code Extension with SQL Notebooks, AI Assistant, and Explorer", "completion": "PgStudio - PostgreSQL VS Code Extension with SQL Notebooks, AI Assistant, and Explorer\nI got tired of switching between VS Code and a separate DB tool. So I built PgStudio.\n\nSQL notebooks with inline results and charts, real-time dashboard, AI assistant (Copilot / OpenAI / Anthropic / Gemini / Ollama — your pick), EXPLAIN CodeLens, visual table designer, production safety controls.\n\nAI never executes anything automatically — every suggestion lands in a notebook cell first.\n\nFree. MIT. One command: \\`code --install-extension ric-v.postgres-explorer\\`\n\nHappy to onboard collaborators and feedback.\n\n\\[[https://pgstudio.astrx.dev/\\](https://pgstudio.astrx.dev/)](https://pgstudio.astrx.dev/](https://pgstudio.astrx.dev/))\n\n\\[[https://github.com/dev-asterix/pgStudio/\\](https://github.com/dev-asterix/pgStudio/)](https://github.com/dev-asterix/pgStudio/](https://github.com/dev-asterix/pgStudio/))", "subreddit": "r/SQL", "upvotes": 4, "date": "[PHONE]", "source": "https://www.reddit.com/r/SQL/comments/1t6geqd/pgstudio_postgresql_vs_code_extension_with_sql/"}
{"prompt": "How would you store execution logs for a production Text-to-SQL agent?", "completion": "How would you store execution logs for a production Text-to-SQL agent?\nI'm currently a 6th semester student and have been interning at a small product-based company 2 months.\n\nThe project I've been working on is a Text-to-SQL agent that queries the company's internal databases. The agent is built using LangGraph and currently consists of around 8 nodes (intentanalysis, table selector, SQL generation, validation, execution, response generation, etc.).\n\nThe next task I've been given is to design a MySQL schema for storing agent logs and execution history.\n\nThe application is multi-tenant, so every request is associated with a tenant and a user. My initial thought was to store fields like tenant\\_id, user\\_email, timestamps, etc. as columns and then store the complete agent output in a JSON column.\n\nA simplified version of the metadata currently generated by the agent looks like this:\n\n\\`\\`\\`json\n\n{\n\n  \"generated\\_sql\": \"SELECT p.id, p.name FROM company\\_product p ...\",\n\n  \"selected\\_tables\": \\[\n\n\"company\\_product\",\n\n\"company\\_product\\_category\"\n\n  \\],\n\n  \"execution\\_time\\_ms\": 16.67,\n\n  \"retry\\_count\": 0,\n\n  \"intent\": \"safe\"\n\n}\n\n\\`\\`\\`\n\nIn addition to this metadata, I can also store intermediate outputs from individual LangGraph nodes if needed.\n\nThe requirements are not fully defined yet, but I can see a few potential use cases:\n\n\\* Debugging incorrect SQL generation\n\n\\* Investigating failed executions\n\n\\* Tracking latency and performance\n\n\\* Auditing what queries were generated and executed\n\n\\* Future analytics (success rate, common failures, usage by tenant, etc.)\n\nOne concern is that the LangGraph workflow will likely evolve over time. Today it has 8 nodes, but that could change in the future, so I'd prefer a design that doesn't require schema changes every time the graph changes.\n\nI'm considering a few approaches:\n\n1. Store tenant/user metadata in columns and dump the entire agent response into a JSON column.\n\n2. Store frequently queried fields (generated\\_sql, execution\\_time\\_ms, status, etc.) as columns while also storing the full JSON payload.\n\n3. Create separate tables such as:\n\n   \\* agent\\_runs\n\n   \\* agent\\_node\\_logs\n\n   \\* execution\\_traces\n\nFor those who have built production LLM agents, LangGraph systems, or observability/logging infrastructure:\n\n\\* How would you design the schema?\n\n\\* Which fields would you normalize into columns versus keep in JSON?\n\n\\* Would you store node-level execution data separately?\n\n\\* Any lessons learned or pitfalls to avoid?\n\nI don't have much experience designing schemas for observability/audit systems, so I'm trying to understand what scales well before implementing something that becomes difficult to maintain.\n\nI'd appreciate examples of schemas or patterns you've used in production", "subreddit": "r/SQL", "upvotes": 4, "date": "[PHONE]", "source": "https://www.reddit.com/r/SQL/comments/1u1xbbg/how_would_you_store_execution_logs_for_a/"}
{"prompt": "HackerRank SQL Project Planning – Is there a better approach?", "completion": "HackerRank SQL Project Planning – Is there a better approach?\nHi everyone,\n\nI solved the HackerRank **SQL Project Planning** problem using the `row_number()` \\+ `DATEADD()` approach in SQL Server, and it passed all the test cases.\n\nI'm curious if there's a different or more optimized way to solve this problem. I'd love to learn other approaches and understand their advantages.\n\nHere's my solution:\n\nwith cte as(\nSELECT start\\_date,\nend\\_date,\ndateadd(day,- row\\_number() over(order by start\\_date),start\\_date) as group\\_date\nfrom projects )\nSELECT min(start\\_date) as start\\_date,\nmax(end\\_date) as end\\_date\nfrom cte\ngroup by group\\_date\norder by datediff(day,min(start\\_date),max(end\\_date)), min(start\\_date)", "subreddit": "r/SQL", "upvotes": 4, "date": "[PHONE]", "source": "https://www.reddit.com/r/SQL/comments/1v46oiv/hackerrank_sql_project_planning_is_there_a_better/"}
{"prompt": "Top alternatives to Datagrip", "completion": "Top alternatives to Datagrip\nBeen using DataGrip for a while, but the cost is getting harder to justify when I only use a fraction of what it offers. My setup is pretty mixed: PostgreSQL, Snowflake, and some MySQL.\n\nI keep seeing DBeaver, DbVisualizer and TablePlus mentioned as alternatives. DBeaver seems like the obvious one, but DbVisualizer caught my attention since it seems geared more toward mixed database environments.\n\nMain things I care about are a good SQL editor/autocomplete, multiple connections without things getting sluggish, and not having to switch tools depending on the database.\n\nFor anyone who's moved away from DataGrip, what did you end up using and how has it held up?", "subreddit": "r/SQL", "upvotes": 4, "date": "[PHONE]", "source": "https://www.reddit.com/r/SQL/comments/1vnsgpu/top_alternatives_to_datagrip/"}
{"prompt": "Experiments: Displaying SQL Table Relationships from the Command Line", "completion": "Experiments: Displaying SQL Table Relationships from the Command Line\nHey everyone! For the past few months, I've been [working on pam](https://github.com/eduardofuncao/pam), which is hybrid CLI/TUI tool for managing and running your sql queries.\n\nOne feature I was trying to implement but couldn't get my head around was a way to display relationships between SQL tables. At first I was trying to use a view similar to ER diagrams, but the results were... well, see it for yourself to see what you think lol\n\nAfter a while and a few discussions with u/Raulnego, we came up with the idea of a tree-like display, which would show relationships between a given table in a recursive flow. Here's the result of the first implementation\n\nOr passing the --depth flag to allow more recursion\n\nAs you can see, it definitely gets messy quick when depth goes up. But I think it could be a really good tool to traverse and understand your database when all you have is the terminal to work with (especially with larger database where a list of all tables would be overwhelming). Let me know what you guys think and if you have any suggestions on alternatives to displaying relationships similar to this! Cheers!", "subreddit": "r/SQL", "upvotes": 4, "date": "[PHONE]", "source": "https://www.reddit.com/r/SQL/comments/1qq74nx/experiments_displaying_sql_table_relationships/"}
{"prompt": "Beginner question: How should I approach databases in C# – raw SQL vs EF Core?", "completion": "Beginner question: How should I approach databases in C# – raw SQL vs EF Core?\nHi everyone,\n\nI’m currently learning backend development with C# / [ASP.NET](http://ASP.NET) Web API and I’m a bit stuck on how to properly start with databases.\n\nRight now I’m experimenting with SQLite, but without EF / EF Core, because I honestly don’t really understand what EF is doing under the hood yet.\n\nMy thinking was: if I first use raw SQL (SqliteConnection, SqliteCommand, etc.), I might build a better mental model of what’s actually happening, instead of relying on abstractions I don’t understand.\n\nHowever, I’m not sure if this approach makes sense long-term or if I’m just making things harder for myself.\n\nSome specific questions I’m struggling with:\n\nIs learning raw SQL + [ADO.NET](http://ADO.NET) first a reasonable path for a beginner in C# backend?\n\nAt what point does EF / EF Core actually become helpful instead of confusing?\n\nIs it common to start without an ORM to understand databases better, or is EF considered “basic knowledge” nowadays?\n\nIf you were starting over today, how would you sequence learning databases in C#?\n\nFor context:\n\nI can build basic APIs (controllers, CRUD endpoints)\n\nI understand SQL fundamentals (SELECT, INSERT, JOIN, GROUP BY)\n\nI’m not aiming for production-ready code yet, just solid understanding\n\nI’d really appreciate advice on learning order and mindset, not just “use EF” or “don’t use EF”.\n\nThanks in advance!", "subreddit": "r/SQL", "upvotes": 4, "date": "[PHONE]", "source": "https://www.reddit.com/r/SQL/comments/1qmnl1s/beginner_question_how_should_i_approach_databases/"}
{"prompt": "I got a lot of responses when I asked about how crazy some of your SQL gets. this is the one I am currently working with that was already done for PowerBuilder query. This is whats used when we pull a report from a console for analyzing wait times from a ticketing system in different locations.", "completion": "I got a lot of responses when I asked about how crazy some of your SQL gets. this is the one I am currently working with that was already done for PowerBuilder query. This is whats used when we pull a report from a console for analyzing wait times from a ticketing system in different locations.\n    select\n    center\n    ,bldg\n    ,queue\n    ,ticket\n    ,date_issued\n    ,time_issued\n    ,first_no_answer\n    ,second_no_answer\n    ,third_no_answer\n    ,time_answered\n    ,time_finished\n    ,wait_time\n    ,case when end_of_day_status='FINISH'\n    and finished_by='USER'\n    and appt_type is not null\n    and motk_appo_time<>trunc(motk_appo_time)\n    and trunc(motk_appo_time)=trunc(motk_time_issued)\n    and motk_time_issued<motk_appo_time\n    and queue in (select moqu_queue from mo_queue where moqu_adjust_waittime='Y'   )\n    then round(decode(first_no_answer,null,(time_answered-motk_appo_time)*86400,(first_no_answer-motk_appo_time)*86400))\n    else round(decode(first_no_answer,null,wait_time,(first_no_answer-motk_time_issued)*86400))\n    end adjusted_wait_time ,service_time ,total_time ,role||' ('||motk_issue_machine||')' issued_from ,user_name||' at '||motk_update_machine last_action_taken_by ,finished_by ,end_of_day_status ,customer_name ,case_no_at_fdr ,cin_at_fdr ,ssn_at_fdr ,decode(queue,'NCA Intake',apin_casenumber,null) case_no_from_intake ,caseload ,appt_type ,appt_time ,visitor_no ,decode(apin_immediate_interview,'Y','SMDAY',flag) flag ,language_at_FDR ,decode(role,'FDR',acm_passes,null) acm_passes ,decode(role,'FDR',adv_passes,null) adv_passes ,decode(role,'FDR',cca_passes,null) cca_passes ,decode(role,'FDR',med_passes,null) med_passes ,decode(role,'FDR',tlr_passes,null) tlr_passes ,decode(role,'FDR',oth_passes,null) oth_passes ,role ,motk_time_issued date_issued_sort ,to_date(time_issued,'hh:mi:ss AM') time_issued_sort ,motk_appo_time appt_time_sort ,(select code_description role from code where code_item_name='MO_ROLE' and code_wms_code = MOTK_ISSUE_MACHINE_ROLE) as MOTK_ISSUE_MACHINE_ROLE from   (select  motk_bldg_id bldg ,motk_cntr_id center ,motk_queue queue ,motk_tkt_no ticket ,motk_time_issued ,to_char(motk_time_issued,'mm/dd/yyyy') date_issued ,to_char(motk_time_issued,'hh:mi:ss AM') time_issued ,motk_time_answered time_answered ,motk_time_finished time_finished ,motk_wait_time wait_time ,motk_activity_time service_time ,motk_total_time total_time ,motk_status end_of_day_status ,decode(motk_finisher,'NO ANS','3rd NoAnswer',null,'NO ONE',motk_finisher) finished_by ,motk_issue_machine ,motk_update_machine ,motk_update_user ,motk_first_name||' '||motk_last_name customer_name ,motk_caseload caseload ,motk_appo_code appt_type ,motk_appo_time ,decode(motk_appo_time,trunc(motk_appo_time),              to_char(motk_appo_time,'mm/dd/yyyy'),              to_char(motk_appo_time,'mm/dd/yyyy hh:mi AM')) appt_time ,motk_visit_id visitor_no ,motk_flag flag ,motk_link_id ,motk_language ,MOTK_ISSUE_MACHINE_ROLE from mo_ticket_history where motk_time_issued between :ar_start and :ar_end   ), (select  mona_bldg_id ,mona_cntr_id ,mona_queue ,mona_tkt_no ,mona_time_issued ,mona_count no_answer_count ,mona_time_noanswered first_no_answer from mo_noanswer_history where mona_count=1 and mona_time_issued between :ar_start and :ar_end   ) a, (select  mona_bldg_id ,mona_cntr_id ,mona_queue ,mona_tkt_no ,mona_time_issued ,mona_count no_answer_count ,mona_time_noanswered second_no_answer from mo_noanswer_history where mona_count=2 a", "subreddit": "r/SQL", "upvotes": 4, "date": "[PHONE]", "source": "https://www.reddit.com/r/SQL/comments/1qh4ybs/i_got_a_lot_of_responses_when_i_asked_about_how/"}
{"prompt": "I built a database manager where drivers are just executables speaking JSON-RPC over stdin/stdout", "completion": "I built a database manager where drivers are just executables speaking JSON-RPC over stdin/stdout\nWorking on Tabularis, an open-source desktop DB manager (Tauri + Rust). Built-in support for MySQL, PostgreSQL, MariaDB, SQLite, but the interesting part is how external drivers work.\n\nPlugin architecture in a nutshell:\n\n* A plugin is a standalone executable dropped into a local folder\n* Tabularis spawns it on connection open, then sends newline-delimited JSON-RPC 2.0 requests to stdin\n* The plugin responds on stdout, logs go to stderr without interfering with the protocol\n* One process instance is reused for the entire session\n\nThe manifest declares capabilities (schemas, views, routines, file\\_based, etc.) so the UI adapts accordingly — no host/port form for file-based DBs, schema selector only if relevant, and so on.\n\nThe RPC surface covers schema discovery (get\\_tables, get\\_columns, get\\_indexes, get\\_foreign\\_keys), query execution with pagination, CRUD, DDL generation, and batch methods for ER diagrams (get\\_schema\\_snapshot, get\\_all\\_columns\\_batch).\n\nThe result: you can write a driver in any language. Current registry has DuckDB and a CSV plugin (treats a folder of .csv files as a database — each file becomes a table). Testing a plugin is just piping JSON to the binary:\n\necho '{\"jsonrpc\":\"2.0\",\"method\":\"get\\_tables\",\"params\":{...},\"id\":1}' | ./my-plugin\n\nCurious if anyone has used a similar approach for extensibility, and what tradeoffs you ran into (vs. shared libraries, HTTP, etc.).\n\nMy project: [https://github.com/debba/tabularis](https://github.com/debba/tabularis)\n\nPlugn Guide: [https://tabularis.dev/wiki/plugins](https://tabularis.dev/wiki/plugins)", "subreddit": "r/SQL", "upvotes": 4, "date": "[PHONE]", "source": "https://www.reddit.com/r/SQL/comments/1rengce/i_built_a_database_manager_where_drivers_are_just/"}
{"prompt": "Primary key, grain of the table and group by", "completion": "Primary key, grain of the table and group by\nCan someone explain me how to understand the difference between them?\n\nWhat I know-\n\n1. Primary key is a column or set of columns that uniquely identifies each row. It may or may not have a business meaning\n\n2. Grain of the table - one row or line item describing what it is, like one row per daily customer session\n\n3. Group by- we use this to get one line item per item of that group. For example something grouped by business type and country, will get me data for unique combination of business type and country\n\nNow I need clarification here-\n\nA primary key should ALWAYS be in a group by statement in SQL or not, if it is needed in the output - True?\n\nA column in group by is not necessary a primary key -True?\n\nColumns defining the grain of the column consists of primary key and other cols (what is the nature of these other cols?)\n\nI am asking these cause while aggregating data I am not sure if I should group all the cols, like sometimes you bring a col whose info you need but aggregating by it will repeat data. Some people say to me to aggregate data by primary key only but what if I have more cols other than primary key. Please correct me if you find flaws in my statements/concept/scenarios.", "subreddit": "r/SQL", "upvotes": 4, "date": "[PHONE]", "source": "https://www.reddit.com/r/SQL/comments/1sxqaaf/primary_key_grain_of_the_table_and_group_by/"}
{"prompt": "Import csv file to mysql", "completion": "Import csv file to mysql\nI am learning sql, I downloaded a dataset from kaggle and cleaned all the excel files. But I am constantly running into this issue where the data in the csv file is not being uploaded. Can sonebody help me please? I would really appreciate it.", "subreddit": "r/SQL", "upvotes": 4, "date": "[PHONE]", "source": "https://www.reddit.com/r/SQL/comments/1tezyja/import_csv_file_to_mysql/"}
{"prompt": "MS SQL Restore DB, <use dbName> string conversion question", "completion": "MS SQL Restore DB,     <use dbName> string conversion question\nHi all,\n\nI just see this interesting situation and would like to confirm that  it's all done internally by SQL with Restore.\nWe're on the same server:\n\n    dbAA   has proc  myPROC:\n    1  use  dbAA\n    2  Go\n    3  Create PROC dbo.myPROC As\n    ............\n\n    then I do  backup of dbAA, and restore dbAA.bkup into  dbXXX\n    after that I see on dbXXX myPROC as:\n    1. use dbXXX            --<<<==== !!!!!<@>>< changed to target DB\n    2. Go\n    3. Create PROC dbo.myPROC As\n    ...........\n\nWho is doing this conversion/swapping db names ? is it done by SQL Server ?\nThanks to all, I'm new to dba task and really interesting how it works.\nVA", "subreddit": "r/SQL", "upvotes": 4, "date": "[PHONE]", "source": "https://www.reddit.com/r/SQL/comments/1v5lub3/ms_sql_restore_db_use_dbname_string_conversion/"}
{"prompt": "I built a tool to trace data flow through legacy SQL pipelines", "completion": "I built a tool to trace data flow through legacy SQL pipelines\nHi! I wanted to share a tool I built to solve a problem that frustrated me for years.\n\nI used to work in an enterprise data team and spent a lot of time digging into legacy SQL pipelines. I spent hours manually reading through SQL and stored procedures because it was difficult and time-consuming to understand exactly how data flowed or how a particular column was transformed along the way.\n\nThe lineage tools and data catalogs I used were useful for understanding high-level dependencies, but they didn't always help when it came to looking into data issues and answering questions like: What caused this value to change? or What would break if I changed this column? I still found myself manually tracing through the SQL.\n\nSo I built a tool that automatically traces data flow through stored procedures at the column level, following transformations step by step and letting you inspect exactly how data moves through the code.\n\nI've attached a demo of one of its features tracing any database column upstream or downstream. Sorry it's a bit long, but I'd really appreciate any feedback. Would something like this be useful in your work?\n\n**Note:** I've marked this post as a brand affiliate because I founded the company behind the tool. I'm still figuring out product-market fit, which is why I'm posting here. I genuinely want to understand whether this solves a real problem for people working with these kinds of SQL estates.", "subreddit": "r/SQL", "upvotes": 4, "date": "[PHONE]", "source": "https://www.reddit.com/r/SQL/comments/1v1mz7w/i_built_a_tool_to_trace_data_flow_through_legacy/"}
{"prompt": "Handling vector indices + branching in Lakebase DB", "completion": "Handling vector indices + branching in Lakebase DB\nMy team is migrating multiple AI applications and currently evaluating Lakebase.\nI wanted to understand if we create a branch fr testing  schema/data changes, are the vector indices isolated as well, or do we need to have an strategy to avoid rebuilding them repeatedly?\nAlso, any performance/operational things you ran into that might help.\nLove to hear from anyone.", "subreddit": "r/SQL", "upvotes": 4, "date": "[PHONE]", "source": "https://www.reddit.com/r/SQL/comments/1v1lb6p/handling_vector_indices_branching_in_lakebase_db/"}
{"prompt": "Calculation for inflation with multiple sub categories please help", "completion": "Calculation for inflation with multiple sub categories please help\nI understand how to calculate yearly change using the lag function, however, I want to do so when I have an unknown number of subcategories between each period. Say i have eggs, bread, and cheese in one year and maybe eggs, oranges, and bread in another year. I want to calculate all inflation yearly changes per each category for every year. Does anyone have any advice on how to accomplish this? Thank you!\n\nex final query result:\n\neggs, 2024, 1.2%\nbread 2024 4%\nbread 2023 0.4%", "subreddit": "r/SQL", "upvotes": 4, "date": "[PHONE]", "source": "https://www.reddit.com/r/SQL/comments/1uvukes/calculation_for_inflation_with_multiple_sub/"}
{"prompt": "What's the best way to practice SQL queries on an Excel spreadsheet on Mac?", "completion": "What's the best way to practice SQL queries on an Excel spreadsheet on Mac?\nI’ve been practicing SQL queries on different pages like sql-practice and data lemur but now I'd like practice on Excel spreadsheets so I can play with the data using SQL queries. What is the best way to do this?\n\nDo I need to download a program or can I do this online? I'm a complete beginner so I'm pretty clueless as to what or where to go.\n\nAlso, I'm using a Mac, so I’m guessing my options are more limited.\n\nThank you in advance!", "subreddit": "r/SQL", "upvotes": 4, "date": "[PHONE]", "source": "https://www.reddit.com/r/SQL/comments/1uqb0h1/whats_the_best_way_to_practice_sql_queries_on_an/"}
{"prompt": "Moving my family business off pen & paper: How do I practice data modeling for a complex, real-world system without breaking operations?", "completion": "Moving my family business off pen & paper: How do I practice data modeling for a complex, real-world system without breaking operations?\nI’m a former junior software developer who recently transitioned into running my family's business. Right now, literally every record is kept via pen, paper, and physical registers. It works, but it's wildly inefficient, completely un-queryable, and doesn't scale.\n\nI want to build a digital system, but I am terrified of breaking what already works. When I sat down to map out the data model, the scope exploded. Tables and fields multiplied fast, and I quickly got overwhelmed trying to ensure the model would support future business questions without painted-in corners.\n\n**The Hurdles:**\n\n* **Scope Creep:** Simple CRUD apps are fine, but modeling an entire, intertwined legacy business is causing massive analysis paralysis.\n* **Fear of Failure:** Since it's production for a live business, an incorrect schema choice could actively hurt day-to-day operations or result in missing data down the line.\n* **Lack of Advanced Practice:** I can design basic relationships, but I lack confidence in advanced, production-grade domain modeling.\n\n**My Questions for the Community:**\n\n1. How do you approach modeling a messy, real-world domain from scratch without getting overwhelmed by the sheer volume of tables?\n2. Are there any specific frameworks, books, or resources that bridge the gap between \"beginner textbook database design\" and \"production-grade enterprise modeling\"? (e.g., Database Design for mere mortals ?)\n\nAppreciate any advice from folks who have transitioned legacy businesses or designed complex domains solo!\n\n#", "subreddit": "r/SQL", "upvotes": 4, "date": "[PHONE]", "source": "https://www.reddit.com/r/SQL/comments/1uokg3f/moving_my_family_business_off_pen_paper_how_do_i/"}
{"prompt": "I made a beginner-friendly SQL JOINs tutorial using PostgreSQL", "completion": "I made a beginner-friendly SQL JOINs tutorial using PostgreSQL\nHey everyone!\n\nI just published a new video about SQL JOINs for beginners.\n\nIn this lesson, I explain:\n\n\\- why relational databases use multiple tables\n\n\\- how JOIN works\n\n\\- INNER JOIN\n\n\\- LEFT JOIN\n\n\\- how the ON condition connects tables\n\n\\- table aliases\n\n\\- how to join multiple tables\n\n\\- and how to combine JOINs with WHERE and ORDER BY\n\nI use the Pagila PostgreSQL database for the examples and practice, so everything is demonstrated with actual data rather than just theory.\n\nI'm building a beginner-friendly SQL tutorial series, so I'd really appreciate any feedback on the explanations or examples!\n\n🎥 Video: https://youtu.be/cRN6ikxtdpo?si=\\_Q2h5e-8BcCAJeYB\n\nThanks for checking it out! :)", "subreddit": "r/SQL", "upvotes": 4, "date": "[PHONE]", "source": "https://www.reddit.com/r/SQL/comments/1w0yizv/i_made_a_beginnerfriendly_sql_joins_tutorial/"}
{"prompt": "Pls help, ssrs 2022 not working after upgrading from sql/ssrs2012", "completion": "Pls help, ssrs 2022 not working after upgrading from sql/ssrs2012\nI upgraded ssrs 2022, configured db and restored encryption key.  Then upgraded sql 2016 to 2022 and that completed.\n\nWhen I went to http://localshost/Reports, it gave me an error about not being configured properly.   /ReportServer shows some error related to wwwroot/ReportServer.\n\nDid some googling, found that ssrs 2022 does not use IIS wwwroot directory.  Checked *keys* table in the ReportServer db and found 2 instances of ssrs (one with new instance name and the other with old instance name from 2016).  Google sear Lin suggests running an sql command to delete all entries, filtered on machinename, then open ssrsbconfiguration and reapply web service url so that it can rewrite run configuration file?\n\nI’m fairly new to sql and found these steps from googling.  I have sysadmi background but have very limited knowledge of sql.\n\nI use Varonis.  How can I fix SSRS 2022 so that Varonis can work again.\n\nTIA", "subreddit": "r/SQL", "upvotes": 4, "date": "[PHONE]", "source": "https://www.reddit.com/r/SQL/comments/1wrmi5d/pls_help_ssrs_2022_not_working_after_upgrading/"}
{"prompt": "Join tables with WITHOUT ROWID.", "completion": "Join tables with WITHOUT ROWID.\n    CREATE TABLE IF NOT EXISTS CourseTag(\n        courseId INTEGER,\n        tagId INTEGER,\n       \n        FOREIGN KEY(courseId) REFERENCES Courses(id),\n        FOREIGN KEY(tagId) REFERENCES Tags(id),\n       \n        PRIMARY KEY(courseId, tagId)\n    ) STRICT WITHOUT ROWID;\n\nas far as what I understand sqlite creates inner row\\_id columns to identify the record. some conditions met then my primary key also could be that unique column. but I guess in above join table configuration my composite key setup is not met that condition so I end up unnecessary column right? in join table should I use `WITHOUT ROWID`?", "subreddit": "r/SQL", "upvotes": 4, "date": "[PHONE]", "source": "https://www.reddit.com/r/SQL/comments/1wju7sb/join_tables_with_without_rowid/"}
{"prompt": "For those who were laid off from a SQL DBA role, how long did it take you to find your next job?", "completion": "For those who were laid off from a SQL DBA role, how long did it take you to find your next job?\nI’m a SQL DBA with 4+ years of experience, currently working at a large company. Unfortunately, I was impacted by restructuring and am now actively looking for a new opportunity.\n\nI’m currently on a visa, and the sponsorship requirements are making the job search more challenging.\n\nFor other DBAs who have gone through a similar job search recently, how long did it take you to land your next position? I’d really appreciate hearing about your experience and any advice you can share.\n\n\nAny suggestions on Job search? Honestly, I am fine with any salary", "subreddit": "r/SQL", "upvotes": 4, "date": "[PHONE]", "source": "https://www.reddit.com/r/SQL/comments/1wb6s46/for_those_who_were_laid_off_from_a_sql_dba_role/"}
{"prompt": "Self Reseting Testing Environment for a School", "completion": "Self Reseting Testing Environment for a School\nI am current working together with a school to provide a sql server that teachers can use to teach their students the basics (SELECT, DELETE, JOIN and so on) of sql.\n\nI am wondering if any type of sql server (doesn’t matter if mysql, mariadb, etc) supports a feature that lets users connect to a „image“ of the database, where they can UPDATE, DELETE, SELECT what they want but only change their connected instance.\n\nSo if for example student 1 deletes all rows and tables. Then student 2 connects and gets a connection to the initial unchanged database. Kind of like a honeypot where attackers can do what they want but as soon as the connection is terminated all session data is erased.\n\nThis would be really useful, because teachers would only have to show one username and password and wouldn’t have to worry about some student deleting everything.", "subreddit": "r/SQL", "upvotes": 4, "date": "[PHONE]", "source": "https://www.reddit.com/r/SQL/comments/1qh4wqk/self_reseting_testing_environment_for_a_school/"}
{"prompt": "‘Fill-in-the-gaps’ courses", "completion": "‘Fill-in-the-gaps’ courses\nLooking for suggestions on training I can take to fill in any gaps I may have with SQL. Have been using it for a long time now (around 20 years), but I’m about to start looking for a new job and all of a sudden I’m having imposter syndrome, wondering if I know as much as I think I know.\n\nSo, any courses you can recommend?\n\nFYI, I’ve looked at the Brent Ozar free classes, loved them, he’s amazing, and I’m pretty sure his paid classes would be too.  But once the exchange rate from the mighty USD is taken into account, the fundamentals+mastering classes would cost me more than a months salary. I’m a single mama who doesn’t often have any cash to splash, so it’s off the table for me.", "subreddit": "r/SQL", "upvotes": 4, "date": "[PHONE]", "source": "https://www.reddit.com/r/SQL/comments/1q5b5w3/fillinthegaps_courses/"}
{"prompt": "Lessons in Grafana - Part Two: Litter Logs", "completion": "Lessons in Grafana - Part Two: Litter Logs\nI recently have restarted my blog, and this series focuses on data analysis. The first entry is focused on how to visualize job application data stored in a spreadsheet. The second entry (linked here), is about scraping data from a litterbox robot. I hope you enjoy!", "subreddit": "r/SQL", "upvotes": 4, "date": "[PHONE]", "source": "https://www.reddit.com/r/SQL/comments/1rcuxye/lessons_in_grafana_part_two_litter_logs/"}
{"prompt": "Assistance With Proper Maintenance Tasks on DB", "completion": "Assistance With Proper Maintenance Tasks on DB\nI’ve been with a new company for about a year now, and during that time I’ve noticed a lack of dedicated database administration and ongoing maintenance from a true DBA. Typically, our infrastructure team is responsible for deploying SQL Server instances, configuring the application according to best practices, and then handing off the database and user access to the application teams. After that point, however, there is little to no ongoing management or maintenance of those databases—whether they are running on Express or Standard editions.\n\nThis recently became more apparent while I was attempting to restore a production database to a test database on the same server. During that process, I discovered that the production database’s transaction log file is approximately 97 GB, while the actual database size is only around 32 GB. Situations like this suggest that routine database maintenance tasks are not being performed.\n\nIn the short term, I’m looking for guidance on what baseline maintenance practices we should implement to properly manage these SQL environments. Longer term, I’d like to be able to propose either bringing on a dedicated DBA or identifying someone who can take ownership of database administration responsibilities.\n\nAny recommendations or best practices would be greatly appreciated.\n\nSome items I've found that could be on the To Do list:\n\n* Full database backups (daily or weekly depending on RPO)\n* Differential backups\n* Transaction log backups\n* Remove expired backup files\n* Review user accounts and roles\n* Remove inactive users\n* Installing CU/SP updates", "subreddit": "r/SQL", "upvotes": 4, "date": "[PHONE]", "source": "https://www.reddit.com/r/SQL/comments/1rswh3d/assistance_with_proper_maintenance_tasks_on_db/"}
{"prompt": "An odd Impala Query Observation", "completion": "An odd Impala Query Observation\nThere was no HIVE/Impala/Hadoop flair, and those subreddits seem stale...\n\n\nI made a mistake today that turned into an observed possible efficiency opportunity, and I'm not sure why.\nI have two giant tables of call data.  The tables are RDBMs tables that have just been dumped into a data lake (HDFS).\n\n\nSomeone had originally written the query without partition pruning. When \"fixing,\" I messed up when adding my partition criteria in order to get the pervious months data.\n\nThere were two tables that were being joined, table i and table ia.  I did:\n\nwhere i.data\\_date >= 20260501\n\nAND ia.data\\_date <= 20260531.\n\n\nI thought I had screwed up, but the query ran in less than 30 seconds.  Figuring it wouldn't be a big deal to put the appropriate uppper and lower bounds on each table, I revised the same query:\n\n\nwhere i.data\\_date >= 20260501\n\nAND i.data\\_date <=20260531\n\nAND ia.data\\_date >= 20260501\n\nAND ia.data\\_date <= 20260531.\n\n\nWhen I ran the query again, it took almost 3 minutes to return the same row count of about 700K records.\n\n\nDid I just get lucky?  Is it possible that being LESS specific allowed the optimizer to somehow created more efficient join plan?  I'm wondering if there is something going on about partitions, parquet stats, and buckets that maybe isn't fully visible to me.\n\n\nMaybe I just got lucky and there were fewer queries running, but because of our platform I can't actually see the useful information about how a query executes, how many workers, bandwidth, etc on the target system.  But is it possible there are some weird things going on about fewer bounds = different/more efficient logic in execution?", "subreddit": "r/SQL", "upvotes": 4, "date": "[PHONE]", "source": "https://www.reddit.com/r/SQL/comments/1uem2wy/an_odd_impala_query_observation/"}
{"prompt": "Looking into possibly transitioning from a marketing role into a DA role. Any advice?", "completion": "Looking into possibly transitioning from a marketing role into a DA role. Any advice?\nHi everyone, a few months ago, I got laid off from my job as a marketer at an agency. I worked with client purchase data, Google Analytics, and Meta data to help give advice on campaigns. Data is something I liked and minored in so it's something I'm happy to learn. But, I was wondering if anyone knows how difficult of a transition it is or if I would need a lot more knowledge to compete with other applicants.", "subreddit": "r/SQL", "upvotes": 4, "date": "[PHONE]", "source": "https://www.reddit.com/r/SQL/comments/1u4e85r/looking_into_possibly_transitioning_from_a/"}
{"prompt": "How do you optimize SQL queries without making them harder to maintain?", "completion": "How do you optimize SQL queries without making them harder to maintain?\nAs databases grow, performance becomes more important, but overly complex queries can be difficult to maintain. How do you balance query optimization with readability in production environments?", "subreddit": "r/SQL", "upvotes": 4, "date": "[PHONE]", "source": "https://www.reddit.com/r/SQL/comments/1vair4u/how_do_you_optimize_sql_queries_without_making/"}
{"prompt": "After converting the back end to SQL tables, the front end now gets run time error 3622 all over the front end", "completion": "After converting the back end to SQL tables, the front end now gets run time error 3622 all over the front end\nI have migrated Access tables in my database over to SQL.  Now I'm testing the front end to make sure every single button/operation works.\n\nI am getting this error, \"You must use the dbSeeChanges option with OpenRecordset when accessing a SQL Server table that has an IDENTITY column\", ALL over the place.\n\nSometimes, it's easy to spot where dbSeeChanges was left out, but many times, the error is reported on a line that has nothing to do with it.  This is also only the first error I'm getting.  I'm sure once I fix all the 3622 errors, then a new error will pop up right after.\n\nI'm wondering what my options are.  I understand I could rebuild the front end from scratch, but that would take literal years as I'm a one-man team.  I really don't have the time to spend hours fixing every single one of these errors.  And unfortunately, throwing it all in the trash and using a modern platform is not currently an option either.\n\nIs there a tool or even AI where I can feed it my database and it converts it to be SQL compatible?  Even if I have to go form by form and report by report, that would still be faster than doing all this manually.\n\nThanks", "subreddit": "r/SQL", "upvotes": 4, "date": "[PHONE]", "source": "https://www.reddit.com/r/SQL/comments/1v4mo6q/after_converting_the_back_end_to_sql_tables_the/"}
{"prompt": "Free portfolio project walkthrough: SQL + Tableau dashboard in 45 minutes (using real IMDb data)", "completion": "Free portfolio project walkthrough: SQL + Tableau dashboard in 45 minutes (using real IMDb data)\nOne of the most common questions I see in this subreddit is \"what projects should I build?\" and the answer is: something with a clear question, real data, and a shareable output.\n\nSo I built a walkthrough for exactly that. It uses two completely free tools:\n\n1. QueryCase's IMDb Sandbox - 250 of the highest rated films on IMDb, queryable in your browser with no setup. You write three SQL queries to answer different questions about the data.\n2. Tableau Public - free, runs in browser, gives you a shareable link when you publish.\n\nThe three queries cover the core of analytical SQL that actually shows up in interviews and jobs: multi-table JOINs, GROUP BY with aggregation, HAVING, subqueries, and derived columns. Each one is explained line by line so you understand why it works, not just what it does.\n\nThe finished dashboard has KPIs, a films-by-decade bar chart, an acclaim vs popularity scatter, top genres by average score, and an actors leaderboard.\n\nThe starter dashboard is just that. The version worth putting on your CV is the one you take further. Add a director leaderboard. Build a decade filter so the whole dashboard slices interactively. Rework the layout and colours until it genuinely looks better than mine. Write a fourth query that answers something the data hasn't told you yet.\n\n\"I built this and then pushed it further\" is a far stronger thing to say in an interview than \"I followed a tutorial.\"\n\nFull walkthrough here with every query written out and all the Tableau steps:\n\n[https://querycase.com/blog/build-an-imdb-dashboard-with-sql-and-tableau](https://querycase.com/blog/build-an-imdb-dashboard-with-sql-and-tableau)\n\nHappy to answer questions about the SQL or the Tableau side if anyone gets stuck.", "subreddit": "r/SQL", "upvotes": 4, "date": "[PHONE]", "source": "https://www.reddit.com/r/SQL/comments/1v4kqtk/free_portfolio_project_walkthrough_sql_tableau/"}
{"prompt": "SQL Server Job, can not edit step on SSMS 2022", "completion": "SQL Server Job, can not edit step  on SSMS 2022\nHi all,\n\nI just installed SSMS 2022 it works fine, new shell I think. But I can not edit step in my SQL Server jobs, I can open its properties, histories though.  I also can edit step from my fav SSMS 2019 on another machine.\nAny google help suggests to install some missing SSIS component, anybody experienced this ?\n\n    TITLE: Microsoft SQL Server Management Studio\n    ------------------------------\n    Unable to find the directories containing Tasks and Data Flow Task components. Check the integrity of your installation.\n    ------------------------------\n    Unable to find the directories containing Tasks and Data Flow Task components. Check the integrity of your installation.\n\nThanks\n\nVA", "subreddit": "r/SQL", "upvotes": 4, "date": "[PHONE]", "source": "https://www.reddit.com/r/SQL/comments/1vpmbja/sql_server_job_can_not_edit_step_on_ssms_2022/"}
{"prompt": "How do i grasp Concepts in SQL easily?", "completion": "How do i grasp Concepts in SQL easily?\nI'm struggling to understand the concepts of sql badly, i mean which framework i mean POV is best for grasping? Could you guys share your thoughts. I want to grasp, so that i can tell to the people like 5 years old kid, non tech persons.", "subreddit": "r/SQL", "upvotes": 4, "date": "[PHONE]", "source": "https://www.reddit.com/r/SQL/comments/1vock2y/how_do_i_grasp_concepts_in_sql_easily/"}
{"prompt": "What database management tool works with both PostgreSQL and Snowflake?", "completion": "What database management tool works with both PostgreSQL and Snowflake?\nFor people working with PostgreSQL and Snowflake regularly, what tool have you settled on, and what still sends you back to a separate client? I work with Dbvisualizer and would like to hear how people handle this setup. For everyday querying, browsing schemas, and exporting results, does using one client make your work easier? Or do differences between the two databases mean you end up switching tools anyway?\n\nWould especially like to hear about anything you only noticed after using a tool for a while. What worked well initially but became frustrating once you were using it every day?", "subreddit": "r/SQL", "upvotes": 4, "date": "[PHONE]", "source": "https://www.reddit.com/r/SQL/comments/1woe9kd/what_database_management_tool_works_with_both/"}
{"prompt": "Read-only dependency mapper for orphaned SQL Agent jobs + SSIS + the scripts that call them, every edge cites its source", "completion": "Read-only dependency mapper for orphaned SQL Agent jobs + SSIS + the scripts that call them, every edge cites its source\nInherited a SQL box where a departed dev left Agent jobs, an SSIS package, and a pile of .bat/.ps1/.rdl/.xlsx files, and untangling what-calls-what by hand was misery. So I wrote a read-only collector (Python/pyodbc) that builds one dependency graph: SQL catalog (sys.objects / sys.sql\\_modules / sys.sql\\_expression\\_dependencies), msdb Agent jobs/steps/history, linked servers, and a file-tree scan that pulls connection strings and linked-table/4-part refs out of .bat/.ps1/.sql/.dtsx/.rdl/.xlsx/.accdb. All read-only (SELECT on catalog views; files opened read-only).\n\nThe part I am happiest with: every edge carries a source citation, a catalog view plus key, a module line, or a byte offset, so you can verify any dependency instead of trusting it. It even catches a linked-server reference buried in dynamic SQL inside a proc (which sys.sql\\_expression\\_dependencies misses) by scanning module text and citing the line. [https://github.com/tommiew007/orphanmap](https://github.com/tommiew007/orphanmap) , MIT.\n\nWhere does this get hard, in your experience? SSIS project-deployment model / SSISDB catalog packages, encrypted modules, synonyms, cross-DB ownership chaining, replication? Curious what breaks it.", "subreddit": "r/SQL", "upvotes": 4, "date": "[PHONE]", "source": "https://www.reddit.com/r/SQL/comments/1wnob0p/readonly_dependency_mapper_for_orphaned_sql_agent/"}
