Here are some sample queries and updates on my database.
This query selects the hard teasers (rating>9).SQL> select id, title, rating from teaser where rating>9 order by rating desc; ID TITLE ---------- ---------------------------------------------------------------- RATING ---------- 4 Body Parts 9.60921
SQL> select id, title from teaser where category = 'Riddle'; ID TITLE ---------- ---------------------------------------------------------------- 1 I Never Was 2 Once in a Minute 3 Food and Water
SQL> select id, title, rating from teaser T1 where not exists ( select * from teaser T2 where T1.rating < T2.rating); ID TITLE ---------- ---------------------------------------------------------------- RATING ---------- 4 Body Parts 9.60921
SQL> select submitted.username,count(*) from account,submitted where submitted.username = account.username group by submitted.username order by count(*) desc; USERNAME COUNT(*) ---------------- ---------- jolefsky 2 JohnC 1 superF 1 turkeyboy 1 babyfishmouth 1
SQL> select teaser.id, title from teaser,submitted where teaser.id = submitted.id and approveddate < submitdate; ID TITLE ---------- ---------------------------------------------------------------- 6 Birthdays
SQL> select id, title, rating from teaser where rating >9 AND id in (select id from featured where numviews > 1000); ID TITLE ---------- ---------------------------------------------------------------- RATING ---------- 4 Body Parts 9.60921
SQL> select username, count(*) from answered where correctP=1 group by username; USERNAME COUNT(*) ---------------- ---------- Brainmaster 1 jolefsky 1
SQL> insert into account values ('shannonc', 'tulip', 1, DATE '2000-02-14', 'shannon@hotmail.com', 'Shannon Conroy'); 1 row created.
SQL> insert into wantsanswer values (2, 'klin'); 1 row created.
SQL> update account set numlogins=numlogins+1, lastlogin = sysdate where username = 'turkeyboy'; 1 row updated.
SQL> update submitted set approved = 'yes', approveddate = sysdate where id = 5; 1 row updated.
SQL> insert into featured select sysdate, 0, id from teaser where id not in (select id from featured) AND rating >= ALL (select rating from teaser where id not in (select id from featured)); 1 row created.
SQL> insert into submitted select id, 'unknown', DATE '1990-01-01', DATE '1990-01-01', 'yes' from teaser where id not in (select id from submitted); 0 rows created.
SQL> delete from account where lastlogin < sysdate - 60; 5 rows deleted.
SQL> delete from teaser where id in (select id from submitted where approved = 'no'); 1 row deleted.