Çë½Ìsql¡£ - MS-SQL Server / ÒÉÄÑÎÊÌâ
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
Ïà¹ØÎÊ´ð£º
select count(1) from FX_RETURNBOOKCHECKLIST fxreturnbo0_ where fxreturnbo0_.BOOKID='164 ' AND fxreturnbo0_.RETURNID='00025.S0000001'
ÉÏÃæÒ»¸ö¼òµ¥µÄSQL,Ö´ÐÐʱ¼ä2.6à ......
tab1 ×Ö¶Î:billdate,goodsid,incount,inmoney,outcount,outmoney,endprice,endcount,endamt
tab2 ×Ö¶Î:goodsid,goodskind£¨ÉÌÆ·ÀàÐÍ£©
tab3 ×Ö¶Î:goodskind£¨ÉÌÆ·ÀàÐÍ£©,kindname
½á¹û£º
µÃµ½ÉÌÆ·ÀàÐÍÔÚÒ»¶Îʱ¼ä ......
×Ö¶Î1,×Ö¶Î2.....×Ö¶ÎN,Status,ParentID
1,Name1....test1,1,99
1,Name1....test1,3,99
1,Name2....test2,1,101
1,Name2....test2,3,101
1,Name3....test3,2,101
1,Name1....test1,4,101
ÏëÒªµÄ½á¹ûÊÇ:
1,Na ......
ÔËÐк󱨴íÎóÈçÏ£º
´íÎóÀàÐÍ£º
Microsoft OLE DB Provider for ODBC Drivers (0x80040E14)
[Microsoft][ODBC Microsoft Access Driver] Óï·¨´íÎó (²Ù×÷·û¶ªÊ§) ÔÚ²éѯ±í´ïʽ 'Êýѧ + 4where ÐÕÃû='Íõ¾²'' ÖС£
......