当前位置:Gxlcms > 数据库问题 > 学习Microsoft SQL Server 2008技术内幕:T-SQL语法基础--第4章

学习Microsoft SQL Server 2008技术内幕:T-SQL语法基础--第4章

时间:2021-07-01 10:21:17 帮助过:4人阅读

TSQLFundamentals2008 select * from Sales.Customers as C where c.country=NSpain select * from Sales.Customers as C where c.country=NSpain and exists(select * from Sales.Orders as O where o.custid=C.custid) select * from Sales.Customers as C where c.country=NSpain and not exists(select * from Sales.Orders as O where o.custid=C.custid) View Code

技术分享

 

 4.3.2 连续聚和

技术分享
select OBJECT_ID(Sales.OrderTotalsByYear)
if OBJECT_ID(Sales.OrderTotalsByYear) is not null  drop view Sales.OrderTotalsByYear

go
create view Sales.OrderTotalsByYear with schemabinding 
as 
  select 
    YEAR(o.orderdate) as orderyear,
    SUM(od.qty) as qty  
  from 
  Sales.Orders as o
    join Sales.OrderDetails as od on o.orderid=od.orderid
  group by YEAR(o.orderdate)
go
View Code

 

学习Microsoft SQL Server 2008技术内幕:T-SQL语法基础--第4章

标签:

人气教程排行