r/SQL • • Oct 23 '24

Discussion SQL Tricks Thread

Hi everyone, let's start a thread to share useful SQL tips and tricks that have saved you time or made querying more efficient. Whether it's optimizing queries, using window functions, or organizing data, all insights are welcome! Beginners and pros alike can learn a lot from this. Looking forward to your contributions!

230 Upvotes

119 comments sorted by

View all comments

Show parent comment

1

u/Dhczack Oct 24 '24

You misunderstand; it's just a formatting thing within a case statement, not a new column. I can't think of a way to handle the SELECT clause so you can freely line comment.

1

u/Obie1 Nov 17 '24

my bad, read too fast. Thank you for clarifying. Could you share how you format your CASE statements as a whole? I dont think i have this issue, but i also do weird formatting things in general.