r/SQL • u/shdw_0x0 • Sep 24 '26
PostgreSQL What SQL concepts do you understand but still forget?
There are some SQL concepts I understand perfectly when I’m using them, but somehow forget when I need them again a few weeks later.
For 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. 😅
Anyone else have a few SQL concepts like this?
125
Upvotes
176
u/ThatSpencerGuy Sep 24 '26
I will always, always have to look up the ROW_NUMBER OVER ( PARTITION BY stuff every time I need to do it.
88
u/GTS_84 Sep 24 '26
PIVOT
I can never remember the god damn syntax for pivoting.
41
u/Jacob_OldStorm Sep 24 '26
I cannot, for the life of me, remember the orders of parameters in datepart and dateadd. I always doubt myself. And does "day" have to be between apostrophes? Who knows...
22
u/Rough-Negotiation880 Sep 24 '26
Almost everything on a bad day.
17
u/DonJuanDoja Sep 24 '26
STUFF... for xml path...
22
u/more_paul Sep 24 '26
I don't forget any concepts. What I forget is syntax for every flavor of date functions out there.
11
u/you_are_wrong_tho Sep 24 '26
anything I havnt touched in the last 6 months I forget until I read about it again
9
u/Zoidburger_ Sep 24 '26
My job requires me to work in 3 different DBMS platforms, so it's always syntax. Is it isnull(), ifnull(), or nvl() in the current DB I'm in?
22
u/Nurgus Sep 24 '26
The pronunciation of SQL as Sequel. It will never not be S.Q.L. inside my head..
7
u/ElHombrePelicano Sep 24 '26
Rank and dense_rank. Use them quite a bit, but not often enough that I don’t have to look up the syntax for these every time.
6
u/infinitetk Sep 24 '26
it's the window functions, rank, row number etc. Always have to look up syntax
5
u/ReleaseTheBlacken Sep 24 '26
Cursor
4
u/gloss2x Sep 24 '26
Having and partition 😭
4
u/CaptainOttar Sep 25 '26
window functions. i literally have to google the exact
partition bysyntax every single time i need a rolling sum.also date math. it's like my brain actively refuses to store how to add a month to a timestamp. thank god for autocomplete and old stackoverflow tabs.
3
u/OkDonkey6524 Sep 24 '26
I can never remember the syntax for date functions.
5
u/TheGenericUser0815 Sep 24 '26
I almost never use between, having and over. CTEs and SPs are daily business for me.
6
u/DamienTheUnbeliever Sep 24 '26
I personally struggle to understand how CTEs are perceived as complicated.
Step 1 - do the tables I'm looking at resemble where I'd want to start with before writing the required query?
Step 2 - if yes, jump to the end
Step 3 - Write queries that re-represent the data sources I have as the source I *wish* I had, and write those as CTEs
Step 4 - Write queries that use the good data sources.
2
u/WBT67 Sep 24 '26
Percentiles
2
u/sam_cat Sep 24 '26
Cte and row-number over xxx
2
u/2Cats3Litterboxes Sep 24 '26
Anything that has anything to do with JSON. I’ve written them, I can read them, I know how they work, but I can’t seem to ever write it on my own without looking up the syntax
2
u/El_Games Sep 24 '26
In Oracle SQL it’s the connect by syntax. I do not only have to look it up each time. It also takes some testing and swearing until I get what I want. But it’s incredibly useful. Same as multicast. I need it rarely but it’s the best way to reverse list_agg strings.
Another one is updating values using a join where you need a PK/FK relationship I think. Its crap but also incredibly useful.
2
u/neophaltr Sep 24 '26
Literally everything. I have devolved into asking Codex
2
u/ArielCoding Sep 25 '26
Any query with more than 3 nested sub queries feels like an archaeologist task.
2
u/pinback77 Sep 25 '26
EXIST has always bugged me for some reason
2
u/Shini_yagami Sep 25 '26
The date functions honestly . I keep mixing up syntax between the different sqls
2
u/Legitimate_Willow905 Sep 25 '26
update with a join is the absolute worst because literally every single dbms handles the syntax completely differently. muscle memory is basically useless there. for recursive stuff like connect by or recursive ctes i don't even try to remember it anymore. i just keep a master text file of snippets on my desktop and blindly copy-paste. saves so much swearing.
1
u/lez_s Sep 24 '26
Rank I have to look up each time and which rank I need to use.
1
u/Hour-Measurement-835 Sep 24 '26
BUILTIN.DF() if you're on NetSuite's SuiteQL. Leave it off a list field and you get internal ids back instead of names, and since no other dialect has it, it never sticks.
1
u/BobDogGo Sep 24 '26
most of the window functions. now that AI can write it for me, I’ll never remember but honestly, it’s more important to know that it exists and how/when/why to use it than the syntax
1
u/Junior_Abalone_8006 Sep 24 '26
IMO no good database developer should know the syntax for any sort of cursors off of the top of their head. You should use them rarely enough that if you have to use one you also have to go back to the documentation and figure out the syntax and basics of using them.
1
u/saymyfuckingname Sep 25 '26
Syntax for date manipulation
1
u/MarkEoghanJones_Art Sep 25 '26
Node specific xml queries.
1
u/jotate Sep 25 '26 edited Sep 25 '26
Merge. And all the windowing features that were introduced after SQL Server 2008 R2 (which is the version I learned everything on originally).
1
u/Negative-Specific-84 Sep 25 '26
For me it is CTE's , Window Functions .... always find them confusing
1
u/Monkeyschool Sep 25 '26
Renaming Columns
1
u/Reasonable-Pay-8771 Sep 25 '26
CTEs for me. I often find myself instead making views of views of views.
1
u/Octoclops8 Sep 25 '26
Statements. all of them.
1
u/MachineParadox Sep 25 '26
Pivot, have to look it up every time
1
u/Specific-Pangolin777 Sep 26 '26
Pivot and unpivot 🤦🏼♀️ I love using them but even with my cheat sheet they make me feel dumb 🤣
1
u/Traditional-Unit-274 Sep 28 '26
i always have to look up ddl sytnax, create table, alter column. it’s so not a big deal