摘要:
透视转换:use tempdb;if object_id('dbo.Orders', 'U') is not null drop table dbo.Orders;create table dbo.Orders( orderid int not null, orderdate date not null, empid int not null, custid varchar(5) not null, aty int not null, constraint pk_Orders primary key(... 阅读全文
posted @ 2013-11-05 09:56
逝者如斯(乎)
阅读(296)
评论(0)
推荐(0)
摘要:
{TODO:} 阅读全文
posted @ 2013-11-05 09:52
逝者如斯(乎)
阅读(142)
评论(0)
推荐(0)
摘要:
1.派生表(derived table)select YEAR(orderdate) as orderyear, COUNT(distinct custid) as numcustsfrom Sales.Ordersgroup by YEAR(orderdate);内联别名select orderyear, COUNT(distinct custid)from (select YEAR(orderdate)as orderyear, custid from Sales.Orders) as Dgroup by orderyear外部命名select orderyear, COUNT(disti 阅读全文
posted @ 2013-11-05 09:48
逝者如斯(乎)
阅读(249)
评论(0)
推荐(0)
摘要:
简单子查询select * from (select custid, companyname from Sales.Customers where country = N'USA') as USACusts关联子查询select custid, orderid, orderdate, empidfrom Sales.Orders as o1where orderid = (select max(o2.orderid) from Sales.Orders as o2 where o2.custid = o1.custid)select orderid, custid, val.. 阅读全文
posted @ 2013-11-05 09:41
逝者如斯(乎)
阅读(192)
评论(0)
推荐(0)
摘要:
{TODO:} 阅读全文
posted @ 2013-11-05 09:39
逝者如斯(乎)
阅读(164)
评论(0)
推荐(0)
浙公网安备 33010602011771号