We've expanded our news coverage and improved our search! Visit
oreilly.com for the latest or search for all things across O'Reilly!
Article:
 |
|
How to Misuse SQL's FROM Clause
|
| Subject: |
|
Another option? |
| Date: |
|
2004-10-22 08:35:21 |
| From: |
|
solutions@netgis.com
|
|
|
|
Should a sub-query in the FROM clause be considered?
select a.CUSTOMER_ID, a.CUSTOMER_NAME
from CUSTOMERS a
join
(select b.CUSTOMER_ID
from ORDERS b
where b.ORDERED_DATE >= ...
group by b.CUSTOMER_ID) b
on
a.CUSTOMER_ID = b.CUSTOMER_ID
where a.ZIP_CODE in ...
order by a.CUSTOMER_NAME
|