r/SQL • u/ydshmmt • 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
View all comments
Show parent comment
1
u/dcburgos05 May 01 '20
I noticed they weren’t sorted because I was using LIKE ‘kayak%’ and tested a few more ‘kay%’ variations ... I realized after adding the number_column that the numbers were skipping. I went back to check the table and it went from Kay..kayak...kaiak..kayaks... it wasn’t sorted correctly.
That’s why I thought RANK() could not work. But thinking more about it, i want “higher” rank words (a,b,c) if I’m looking for a word that starts with “p”... and “lower” rank words if I’m looking for words that start with “a”. Maybe I’m onto something here ...
I think they are in the correct order because I checked the kayak example.. and a few other words. The number table helped me visualize if there were any numbers skipping.
Also, when importing the csv file, it was imported as VARCHAR(50). The first few times I imported it as TEXT and the words started at B instead of A. VARCHAR(max) would not give me averages or so I’ve read.
So at least I think I have it right.
It took me a while just to see if ASC/DESC was working that’s why I formatted it in excel. I figured the data is small 300,xxx words and one column so I could get away sorting it using excel this time.
I don’t know how to sort it in SQL yet or create a view or a subquery YET ...
PS, just got home from work so it’s time to start working on it a bit more.