SQL code:
if object_id('tb') is not null
drop table tb
create table tb(type varchar(20),accessoryNo varchar(20),deviceNo varchar(10),lastTime decimal(27,6))
insert tb
select 'A','s10','z11',10 union all
select 'B','s10','z11',11 union all
select 'A','s11','z12',51 union all
select 'A','s10','z11',91 union all
select 'A','s10','z13',29 union all
select 'B','s10','z11',30 union all
select 'B','s10','z11',50 union all
select 'B','s10','z11',85 union all
select 'A','s10','z11',60 union all
select 'A','s10','z11',30 union all
select 'B','s10','z11',33
--要求的查询结果
/*
型别 合计 10以下 10-30 31-60 61-90 90以上
A 6 0 3 2 0 1
B 5 0 2 2 1 0
合计 11 0 5 4 1 1
*/
drop table tb
--查询语句应该怎么写呢?
SQL code:
with t as(
select [type] as 型别,
count(*) as 合计,
(select count(*) from tb as tt1 where lastTime<10 and tt1.[type] = t1.[type]) as [10以下],
(select count(*) from tb as tt2 where lastTime between 10 and 30 and tt2.[type] = t1.[type]) as [10至30],
(select count(*) from tb as tt3 whe
可能因为工作的原因 接触数据库这块比较少,之前都是做程序这块,数据库这块都有专门的人来做 分工都很明细 所以对数据库这一块完全不了解。前段时间 去面试了几家公司 几乎都是在数据库这块挂掉的 连个简单的SQ ......
sqlserver2005 建立的数据库,与手持pda传输数据,最近突然出现无法传递数据的问题,pda端提示的错误时outofmemoryexception,但是pda上面的容量没有问题,
sqlserver的日子上的错误如下:
日期 2010-1-25 14:45: ......