您的位置:首页 > 数据库

sql server 2008语言基础: 集合

2012-04-11 13:28 323 查看
--declare @t table(n int)
--insert into @t values(0),(1),(2),(3),(4),(5),(6),(7),(8),(9)
--select * from @t

--返回在2008年1月有订单活动, 而在08年2月没有订单活动的客户和雇员.
--select custid, empid from Sales.Orders where orderdate>='2008-01-01' and orderdate<'2008-02-01'
--except
--select custid, empid from Sales.Orders where orderdate>='2008-02-01' and orderdate<'2008-03-01'

--返回在08年1月和2月都有订单活动的客户和雇员
--select custid, empid from Sales.Orders where orderdate>='2008-01-01' and orderdate<'2008-02-01'
--intersect
--select custid, empid from Sales.Orders where orderdate>='2008-02-01' and orderdate<'2008-03-01'

--在08年1月和2月有, 在07年没有的客户和雇员
--(select custid, empid from Sales.Orders where orderdate>='2008-01-01' and orderdate<'2008-02-01'
--intersect
--select custid, empid from Sales.Orders where orderdate>='2008-02-01' and orderdate<'2008-03-01'
--)
--except
--select custid, empid from Sales.Orders where orderdate>='2007-1-01' and orderdate<'2008-01-01'

select country,region,city from hr.Employees
union all
select country,region,city from Production.Suppliers


.csharpcode, .csharpcode pre
{
font-size: small;
color: black;
font-family: consolas, "Courier New", courier, monospace;
background-color: #ffffff;
/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt
{
background-color: #f4f4f4;
width: 100%;
margin: 0em;
}
.csharpcode .lnum { color: #606060; }
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: