Ò׽ؽØͼÈí¼þ¡¢µ¥Îļþ¡¢Ãâ°²×°¡¢´¿ÂÌÉ«¡¢½ö160KB

mssql sql¼ò»¯

SQL code:

declare @begin datetime --¿ªÊ¼Ê±¼ä
declare @end datetime --½áÊøʱ¼ä
declare @startIndex int --ÆðʼֵĬÈÏΪ8
declare @interval int --ʱ¶Î³¤
select @startIndex=8
select @interval=12

if @interval=6
begin

select stcd,convert(varchar(10),TM,20)'ÈÕÆÚ',sum(dyp)'ÈÕÓêÁ¿',
sum(case when @startIndex+@interval=14 then p8+p9+p10+p11+p12+p13 else 0 end) 'h14',
sum(case when @startIndex+@interval=20 then p14+p15+p16+p17+p18+p19 else 0 end) 'h20',
sum(case when @startIndex+@interval=26 then p20+p21+p22+p23+p0+p1 else 0 end) 'h02',
sum(case when @startIndex+@interval=32 then p2+p3+p4+p5+p6+p7 else 0 end) 'h08'
from st_rain_s where tm>'2009-3-01' and tm<'2010-4-2'
group by stcd,convert(varchar(10),TM,20)

end
else if @interval=8
begin

select stcd,convert(varchar(10),TM,20)'ÈÕÆÚ',sum(dyp)'ÈÕÓêÁ¿',
sum(case when @startIndex+@interval=16 then p8+p9+p10+p11+p12+p13+p14+p15 else 0 end) 'h16',
sum(case when @startIndex+@interval=20 then p16+p17+p18+p19+p20+p21+p22+p23 else 0 end) 'h24',
sum(case when @startIndex+@interval=26 then p0+p1+p2+p3+p4+p5+p6+p7 else 0 end) 'h08'
from st_rain_s where tm>'2009-3-01' and tm<'2010-4-2'
group by stcd,convert(varchar(10),TM,20)

end
else
begin

select stcd,convert(varchar(10),TM,20)'ÈÕÆÚ',sum(dyp)'ÈÕÓêÁ¿',
sum(case when @startIndex+@interval=16 then p8+p9+p10+p11+p12+p13+p14+p


Ïà¹ØÎÊ´ð£º

sqlÓï¾ä¶à±í¶à×ֶβéѯ - MS-SQL Server / »ù´¡Àà

ÎÒÓжà¸ö±íA B C ½á¹¹ÊÇÒ»ÑùµÄ£¬¶¼ÓÐ2¸ö×Ö¶ÎnameºÍcontent,ÎÒÒªËÑË÷ËùÒÔ±íËùÓÐ×Ö¶ÎÖаüº¬¡°Öйú¡±µÄÄÚÈÝ Õâ¸öSQLÓï¾äÔõôд 

ÈçºÎ½«¶à¸ö±íµÄ²éѯ½á¹ûÁ¬³ÉÒ»¸ö±í Õâ¸öSQLÓï¾äÔõôд ±íµÄ½á¹¹ÊÇÒ»ÑùµÄ
ÀýÈç£ ......

Çë½ÌsqlÓï¾ä¡£ - Oracle / ¿ª·¢

ÎÒÓÐÒ»¸ö±í£¬½á¹¹ÊÇÕâÑù¡£
  ת³ö µ¥Î» תÈ뵥λ ±ÊÊý ½ð¶î
date(Ö÷) outid(Ö÷) inid(Ö÷) num amt
2009 1 2 1 500 Ϊ 1 µ¥Î» ÔÚ2009Ä ......

Êý¾ÝÒÔxml¸ñʽ·µ»Ø - MS-SQL Server / Ó¦ÓÃʵÀý

´ÓÊý¾Ý¿âÖвéѯһÕűíµÄÊý¾Ý
select ²¿ÃÅ,ÐÕÃû from tb
ÈçºÎ²ÅÄÜÉú³ÉÏÂÃæµÄxml¸ñʽ
XML code:
<folder state="unchecked" label="È«²¿">
¡¡¡¡ <folder state="unchecked&qu ......

Ò»¸öpl/sqlÎÊÌâ - Oracle / ¿ª·¢

ÎÒÊÇÔÚtoadÖÐÊäÈë϶Îsql
  declare
  TYPE test_rec IS record(
  code varchar(10),
  name varchar(30)
  );
  v_book test_rec;
    ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØͼ | ¸ÓICP±¸09004571ºÅ