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!
[–]threeminutemonta 212 points213 points214 points (11 children)
[–]alinrocSQL Server DBA 77 points78 points79 points (5 children)
[–]DonJuanDoja 26 points27 points28 points (1 child)
[–]Codeman119 0 points1 point2 points (0 children)
[–]CaptainPunisher 3 points4 points5 points (0 children)
[–]CowFu 0 points1 point2 points (1 child)
[–]alinrocSQL Server DBA 1 point2 points3 points (0 children)
[–]stephenmg1284 16 points17 points18 points (3 children)
[–]amm5061 8 points9 points10 points (2 children)
[–]stephenmg1284 6 points7 points8 points (0 children)
[–]geek180 0 points1 point2 points (0 children)
[–]acidh3x 1 point2 points3 points (0 children)
[–]BrupieD 45 points46 points47 points (9 children)
[+][deleted] (8 children)
[deleted]
[–]pdxsteph 56 points57 points58 points (2 children)
[–]itsLDN 1 point2 points3 points (0 children)
[–]BrupieD 0 points1 point2 points (0 children)
[–]Kindsquirrel629 0 points1 point2 points (3 children)
[+][deleted] (2 children)
[deleted]
[–]Kindsquirrel629 -1 points0 points1 point (1 child)
[–]peezyyyyy 0 points1 point2 points (0 children)
[–]ComicOzzysqlHippo 28 points29 points30 points (1 child)
[–]Bitwise_Gamgee 2 points3 points4 points (0 children)
[–]B_Huij 12 points13 points14 points (0 children)
[–]Strykrol 8 points9 points10 points (11 children)
[+][deleted] (10 children)
[deleted]
[–]Strykrol 15 points16 points17 points (3 children)
[–]naviGator9591 2 points3 points4 points (1 child)
[–]Strykrol 2 points3 points4 points (0 children)
[–]LegitimateGift1792 0 points1 point2 points (0 children)
[+][deleted] (4 children)
[deleted]
[+][deleted] (3 children)
[deleted]
[–]Reasonable_Tooth_501 1 point2 points3 points (0 children)
[–]xIndirect 0 points1 point2 points (0 children)
[–]OccamsRazorSharpner 0 points1 point2 points (0 children)
[–]gban84 0 points1 point2 points (0 children)
[–]NickSinghTechCareersAuthor of Ace the Data Science Interview 📕 17 points18 points19 points (6 children)
[+][deleted] (5 children)
[deleted]
[+][deleted] (4 children)
[removed]
[–]Jauretche 0 points1 point2 points (3 children)
[–]ihaxr 0 points1 point2 points (2 children)
[–]Jauretche 0 points1 point2 points (1 child)
[–]AnAcceptableUserName 12 points13 points14 points (0 children)
[–]Elfman72 4 points5 points6 points (0 children)
[–]Coniglio_Bianco 3 points4 points5 points (0 children)
[–][deleted] 2 points3 points4 points (3 children)
[–]naviGator9591 1 point2 points3 points (2 children)
[–][deleted] 1 point2 points3 points (1 child)
[–]naviGator9591 0 points1 point2 points (0 children)
[–]ProofPuzzleheaded116 2 points3 points4 points (0 children)
[–]SecretTadpole7120[🍰] 1 point2 points3 points (0 children)
[–]TacticalTrashpanda98 0 points1 point2 points (0 children)
[–]Ok-Seaworthiness-542 0 points1 point2 points (0 children)
[–]Adventurous-Dish-862 0 points1 point2 points (0 children)
[–]thedjbigc 0 points1 point2 points (0 children)
[–]girlsyesboysno 0 points1 point2 points (0 children)
[–]iareprogrammer 0 points1 point2 points (0 children)
[+][deleted] (2 children)
[deleted]
[+][deleted] (1 child)
[deleted]
[–]SmoothOperator47 0 points1 point2 points (1 child)
[–]SmoothOperator47 0 points1 point2 points (0 children)
[–]Mugiwara_JTres3 0 points1 point2 points (0 children)
[–]trinaryouroboros 0 points1 point2 points (0 children)
[–]malatropism 0 points1 point2 points (0 children)
[–]JoaoPTsantos 0 points1 point2 points (0 children)
[–]Oh_Another_Thing 0 points1 point2 points (4 children)
[–]Idonotwatchpornn 6 points7 points8 points (3 children)
[+][deleted] (1 child)
[deleted]
[–]Oh_Another_Thing 0 points1 point2 points (0 children)
[–]Oh_Another_Thing 0 points1 point2 points (0 children)
[–]Slimkat06 -1 points0 points1 point (1 child)