|
|
|
|
你现在的位置:您现在的位置是: 中国ASP>>数据库>>sql server |
|
| 使用派生表 |
|
1.此示例使用派生表和紧跟 FROM 子句的 SELECT 语句,返回所有作者的姓名以及所著书的标题的书号。
USE pubs SELECT RTRIM(a.au_fname) + '''' '''' + LTRIM(a.au_lname) AS Name, d1.title_id FROM authors a, (SELECT title_id, au_id FROM titleauthor) AS d1 WHERE a.au_id = d1.au_id ORDER BY a.au_lname, a.au_fname 2。相当于 case的 select distinct (ww.dates),(select price from adt1 b where id=1 and ww.dates=b.dates)as w1,(select price from adt1 c where id=2 and ww.dates=c.dates)as w2,(select price from adt1 d where id=3 and ww.dates=d.dates)as w3 from adt1 ww order by ww.dates 3。select a.dates,a.price as w1,b.price as w2,c.price as w3 from (select * from tablename where id=1)as a, (select * from tablename where id=2 )as b, (select * from tablename where id=3) as c where a.dates=b.dates and b.dates=c.dates order by a.dates
|
|
|