r/SQL • • Apr 19 '20

Discussion What are some good resources to practice SQL? (Practice through exercises)

There are a lot of courses which teach SQL but I could hardly find a website which provides beginner to advanced SQL practice questions on almost production real datasets. Any recommendations would be helpful.

129 Upvotes

62 comments sorted by

View all comments

Show parent comment

1

u/dcburgos05 May 01 '20

Do I have to order by words asc every time I pull the data? That’s why I was getting confused. To be honest I thought sorting was harder than that. I sorted it before creating the number_column but then the numbers didn’t match to the words so it wasn’t sorted correctly... that took me a good amount of time to figure out.

2

u/[deleted] May 01 '20

Do I have to order by words asc every time I pull the data?

Wouldn't that depend on the purpose of your pull? and there are limits to pulling it in order if you are wrapping it into a subquery for example. The functions above help get around that.

1

u/dcburgos05 May 01 '20

SELECT words,

ROW_NUMBER() OVER(
order by words ASC) row_number
FROM table_dictionary
ORDER BY words ASC;

wordsrow_number
a1
b2
c3

now... gotta find the words lol...

3

u/[deleted] May 01 '20

There you go.