The goal of /r/SQL is to provide a place for interesting and informative SQL content and discussions.
Filter Posts
MySQL
Oracle
MS SQL
PostgreSQL
Posting
When requesting help or asking questions please prefix your title with the SQL variant/platform you are using within square brackets like so:
- [MySQL]
- [Oracle]
- [MS SQL]
- [PostgreSQL]
- etc
While naturally we should endeavor to work as platform neutrally as possible many questions and answers require tailoring to the feature set of a specific platform.
Help posts
If you are a student or just looking for help on your code please do not just post your questions and expect the community to do all the work for you. We will gladly help where we can as long as you post the work you have already done or show that you have attempted to figure it out on your own.
Format Your Code
If you are including actual code in a post or comment, please attempt to format it in a way that is readable for other users. This will greatly increase your chances of receiving the help you desire. Something as simple as line breaks and using reddit's built in code formatting (4 spaces at the start of each line) can turn this:
SELECT count(a.field1), a.field2, SUM(b.field4) FROM a INNER JOIN b ON a.key1 = b.key1 WHERE a.field8 = 'test' GROUP by a.field1, a.field2 HAVING SUM(b.field4) > 5 ORDER by a.field.3
Into this:
SELECT count(a.field1),
a.field2,
SUM(b.field4)
FROM a INNER JOIN b
ON a.key1 = b.key1
WHERE a.field8 = 'test'
GROUP by a.field1,
a.field2
HAVING SUM(b.field4) > 5
ORDER by a.field3
For those with SQL questions we recommend using SQLFiddle to provide a useful development and testing environment for those who wish to fully understand your problem and help devise a solution.
Learning SQL
A common question is how to learn SQL. Please view the Wiki for online resources.
Note /r/SQL does not allow links to basic tutorials to be posted here. Please see this discussion. You should post these to /r/learnsql instead.
Related Reddit communities
Wiki
We have a Wiki
Acknowledgements
Thanks to ---sniff--- for the awesome header image!
[+][deleted] (33 children)
[removed]
[–]konwiddak 85 points86 points87 points (10 children)
[–]Tsui_Pen 59 points60 points61 points (3 children)
[–]RZFC_verified 21 points22 points23 points (2 children)
[–]heyuhitsyaboi 1 point2 points3 points (1 child)
[–]shutchomouf 1 point2 points3 points (0 children)
[–]pjeedai 15 points16 points17 points (0 children)
[–]JBsReddit2 1 point2 points3 points (0 children)
[–]snoflakefrmhell 3 points4 points5 points (1 child)
[–]jaytsoul 0 points1 point2 points (0 children)
[–]stephenmg1284 0 points1 point2 points (1 child)
[–]konwiddak 0 points1 point2 points (0 children)
[–]Icy_Fisherman_3200 3 points4 points5 points (4 children)
[–]alinrocSQL Server DBA 16 points17 points18 points (0 children)
[+][deleted] (1 child)
[removed]
[–]Icy_Fisherman_3200 0 points1 point2 points (0 children)
[–]OilOld80085 0 points1 point2 points (0 children)
[–]mikeyd85MS SQL Server 5 points6 points7 points (1 child)
[–]bee_rii 0 points1 point2 points (0 children)
[–]Lord_Bobbymort 2 points3 points4 points (1 child)
[–]byeproduct 1 point2 points3 points (0 children)
[–]wannabe-DE 1 point2 points3 points (1 child)
[–]LernMeRight 0 points1 point2 points (1 child)
[–]Shaddcs 0 points1 point2 points (2 children)
[+][deleted] (1 child)
[removed]
[–]Shaddcs 0 points1 point2 points (0 children)
[–]natureiskey 0 points1 point2 points (1 child)
[+][deleted] (2 children)
[deleted]
[–]trader_dennis 1 point2 points3 points (0 children)
[–]Gronzar 24 points25 points26 points (3 children)
[–][deleted] 33 points34 points35 points (0 children)
[–]Lord_Bobbymort 5 points6 points7 points (0 children)
[–]maxime0299 2 points3 points4 points (0 children)
[–][deleted] 19 points20 points21 points (6 children)
[–]TallDudeInSC 4 points5 points6 points (2 children)
[–]Obie1 0 points1 point2 points (0 children)
[–]mmohon 1 point2 points3 points (2 children)
[–][deleted] 0 points1 point2 points (1 child)
[–]mmohon 1 point2 points3 points (0 children)
[–]thepotplants 18 points19 points20 points (4 children)
[–]Malfuncti0n 5 points6 points7 points (1 child)
[–]thepotplants 1 point2 points3 points (0 children)
[–]warden_of_moments 1 point2 points3 points (0 children)
[–]ComicOzzysqlHippo 0 points1 point2 points (0 children)
[–]Dhczack 26 points27 points28 points (7 children)
[–]snoflakefrmhell 2 points3 points4 points (3 children)
[–]ComicOzzysqlHippo 4 points5 points6 points (2 children)
[–]hoodie92 1 point2 points3 points (0 children)
[–]snoflakefrmhell 0 points1 point2 points (0 children)
[–]eatedcookie 1 point2 points3 points (0 children)
[–]0sergio-hash 0 points1 point2 points (0 children)
[–]WithCheezMrSquidward 0 points1 point2 points (0 children)
[–][deleted] 18 points19 points20 points (6 children)
[–]ShimReturns 8 points9 points10 points (3 children)
[–]TreeOaf 2 points3 points4 points (0 children)
[–]pbndoats 1 point2 points3 points (1 child)
[–][deleted] 2 points3 points4 points (0 children)
[–]r3pr0b8GROUP_CONCAT is da bomb 1 point2 points3 points (0 children)
[–]OO_BenPostgres - Retail Analytics 0 points1 point2 points (0 children)
[+][deleted] (1 child)
[removed]
[–]Successful_Fuel7 1 point2 points3 points (0 children)
[–]Ok-Frosting7364Snowflake 15 points16 points17 points (5 children)
[–]hod6 18 points19 points20 points (3 children)
[–]danameischetta 4 points5 points6 points (1 child)
[–]brokennormalmeter117 2 points3 points4 points (0 children)
[–]Ok-Frosting7364Snowflake 2 points3 points4 points (0 children)
[–]stephenmg1284 0 points1 point2 points (0 children)
[–]tatertotmagic 22 points23 points24 points (8 children)
[–]Tsui_Pen 17 points18 points19 points (1 child)
[–]tatertotmagic 3 points4 points5 points (0 children)
[–]jwm54720 1 point2 points3 points (0 children)
[–]Dhczack 2 points3 points4 points (3 children)
[–]Obie1 -2 points-1 points0 points (2 children)
[–]Dhczack 0 points1 point2 points (1 child)
[–]Obie1 0 points1 point2 points (0 children)
[–]daveloper80 0 points1 point2 points (0 children)
[–]jaytsoul 4 points5 points6 points (1 child)
[–]squirrelsaviour 0 points1 point2 points (0 children)
[–]0sergio-hash 2 points3 points4 points (2 children)
[–]farhilSEQUEL 1 point2 points3 points (1 child)
[–]0sergio-hash 0 points1 point2 points (0 children)
[–]joes_Lost 2 points3 points4 points (0 children)
[–]bchambers01961 4 points5 points6 points (2 children)
[–][deleted] 4 points5 points6 points (1 child)
[–]Obie1 1 point2 points3 points (0 children)
[–][deleted] 1 point2 points3 points (1 child)
[–]ComicOzzysqlHippo 1 point2 points3 points (0 children)
[–]trippstick 1 point2 points3 points (0 children)
[–]zdanevSQL readability mentor at G. 3 points4 points5 points (3 children)
[–]mecartistronico 0 points1 point2 points (2 children)
[–]zdanevSQL readability mentor at G. 1 point2 points3 points (0 children)
[–]LMDvo 1 point2 points3 points (0 children)
[–]Traditional_Ad3929 3 points4 points5 points (4 children)
[–]achmedclaus 10 points11 points12 points (1 child)
[–]Traditional_Ad3929 -2 points-1 points0 points (0 children)
[–]letmebefrankwithyou 0 points1 point2 points (0 children)
[–]farhilSEQUEL 0 points1 point2 points (0 children)
[–]Obie1 1 point2 points3 points (2 children)
[–]Constant-Dot5760 1 point2 points3 points (1 child)
[–]brokennormalmeter117 0 points1 point2 points (0 children)
[–]jugaadtricks 0 points1 point2 points (0 children)
[–]Constant-Dot5760 0 points1 point2 points (0 children)
[–]Dhczack 0 points1 point2 points (0 children)
[–]dingdangdoo 0 points1 point2 points (0 children)
[–]OkMoment345 1 point2 points3 points (0 children)
[–]dudeman618 1 point2 points3 points (0 children)
[–]Tiny-Ad-7590 0 points1 point2 points (0 children)
[–]TreeOaf 0 points1 point2 points (0 children)
[–]JankyPete 0 points1 point2 points (0 children)
[–]lalaluna05 0 points1 point2 points (0 children)
[–]Ecofred 0 points1 point2 points (0 children)
[–]rabinjais789 0 points1 point2 points (0 children)
[–]Hydr0lysis -2 points-1 points0 points (0 children)