Saturday, December 17, 2005

Interactive SQL tutorial



I have tested myself with 'a gentle introduction to SQL'. Questions are asked and you have to come up with the SQL that gives the right answer. You SQL is run on a database somewhere in real time.

You can practice SQL Server, Oracle, MySQL, DB2, Mimer SQL, PostgreSQL and Access.

An example:

Question:

A "good value" album is one where the price per track is less than 50 pence. Find the good value album - show the title, the price and the number of tracks.

Answer: (MySQL)

select album.title, album.price, count(song)
from album
JOIN track ON (asin=album)
group by asin
having price/count(song) < .50

Highly recommended. Both to learn SQL and for its pedagogical approach. The theory is available to those who needs/wants it by clicking a link on the question page. No correct SQL's are given, but the right records and fields for each question may be displayed to help one to come on the right track.

(Via J-Walk)

2 comments:

Anonymous said...

title instead of asin gives the correct answer

Unknown said...

"SQLZOO"

Hi,

This gives the correct solution.

select album.title, album.price, count(track.song)
from album join track
on (album.asin = track.album)
group by album.title, album.price
having album.price/count(track.song) < 0.5