摘要: 每个城市中属于每种类别的消费者的数量select city,no_orders,upto_two_orders,more_than_two_orders from(select c.customerid,city,case when count(orderid) = 0 then 'no_orders' when count(orderid) <=2 then 'upto_two_orders' when count(orderid) >2 then 'more_than_two_orders'end as categoryfrom 阅读全文
posted @ 2012-04-26 11:38 pnljs 阅读(569) 评论(0) 推荐(0) 编辑
摘要: SQLNorthWind表格说明-------------------------Categories:种类表 --相应字段:CategoryID :类型ID;CategoryName:类型名;Description:类型说明;Picture:产品样本-------------------------CustomerCustomerDemo:客户类型表1--相应字段:CustomerID:客户ID;CustomerTypeID:客户类型ID-------------------------CustomerDemographics:客户类型表2--相应字段:CustomerTypeID:客户类型 阅读全文
posted @ 2012-04-26 10:59 pnljs 阅读(1541) 评论(0) 推荐(0) 编辑
摘要: --表结构:if exists (select * from sysobjects where id = OBJECT_ID('[表1]') and OBJECTPROPERTY(id, 'IsUserTable') = 1) DROP TABLE [表1] CREATE TABLE [表1] ( [ID] [int] NULL , [NAME] [varchar] (10) NULL , [QQ] [varchar] (10) NULL , [PHONE] [varchar] (20) NULL )INSERT [表1] ( [ID] , [NAME] , [ 阅读全文
posted @ 2012-04-26 09:35 pnljs 阅读(401) 评论(0) 推荐(0) 编辑