Take a look at the SUGI papers on SQL...
Here's one you might like
happy reading -
DDS Data Extraction
From: Charles Patridge [mailto:charles_s_patridge@PRODIGY.NET]
Sent: Friday, September 26, 2003 10:50 AM
Subject: Re: learning SQL
SAS Guide to the SQL Procedure - Usage and Reference - Version 6, 1st
Edition, #56070, ISBN 1-55544-367-2, 7th printing, January 1996
is a pretty good tutorial manual on SQL and Subqueries are included too.
SAS phone 919-677-8000 or you could try their website at http://www.sas.com