SQL²éѯÎÊÌâÇó½Ì£¿
select a.fyear,b.fname,
'1ÔÂ'=case when fperiod=1 then sum(a.fendbal) else 0 end ,
'2ÔÂ'=case when fperiod=2 then sum(a.fendbal) else 0 end ,
'3ÔÂ'=case when fperiod=3 then sum(a.fendbal) else 0 end ,
'4ÔÂ'=case when fperiod=4 then sum(a.fendbal) else 0 end ,
'5ÔÂ'=case when fperiod=5 then sum(a.fendbal) else 0 end ,
'6ÔÂ'=case when fperiod=6 then sum(a.fendbal) else 0 end ,
'7ÔÂ'=case when fperiod=7 then sum(a.fendbal) else 0 end ,
'8ÔÂ'=case when fperiod=8 then sum(a.fendbal) else 0 end ,
'9ÔÂ'=case when fperiod=9 then sum(a.fendbal) else 0 end ,
'10ÔÂ'=case when fperiod=10 then sum(a.fendbal) else 0 end ,
'11ÔÂ'=case when fperiod=11 then sum(a.fendbal) else 0 end ,
'12ÔÂ'=case when fperiod=12 then sum(a.fendbal) else 0 end
from openrowset('sqloledb','192.168.12.101';'sa';'',ais20080707094757.dbo.icinvbal) as a
inner join openrowset('sqloledb','192.168.12.101';'sa';'',ais20080707094757.dbo.t_stock) as b
on a.fstockid=b.fitemid
group by a.fyear,a.fperiod,b.fname
order by b.fname
--²éѯ½á¹û
Äê¶È ²Ö¿â 1Ô ¶þÔ ÈýÔ ËÄÔ ÎåÔ ÁùÔ ÆßÔ 
Ïà¹ØÎÊ´ð£º
СµÜÊǸöÐÂÊÖ ÏÖÔÚÓиöÎÊÌâÒ»Ö±²»Äܽâ¾ö
ÀýÈç
procedure produce_proc
@p001 nvarchar(8000),
@p002 nvarchar(8000),
@p003 nvarchar(8000),
& ......
sql2005
select *from v_ddxx where d_sfsc='0' and (g_ssbm='1001' or g_ssbm='1002') and (xxf>0 and xxfwzf <>0 ),Ö´ÐÐËÙ¶ÈÂýµÄÒªËÀ£¬µ«ÊÇÈç¹û°Ñ(xxf>0 and ......
½«Ò»¸ö±í21~30ɾ³ý£¬sqlÓï¾äÔõôд
Õâ¸öÌ«ÁýͳÁË£¬ÊÇÅÅÐòºóµÄµÚ21Ìõµ½30Ìõ¼Ç¼ɾ³ý»¹ÊÇijһÁÐÖµÔÚ21µ½30Ö®¼äµÄɾ³ý°¡£¿
21-30ÊÇʲôÒâ˼£¿×ֶεĻ°¾Ídelete from table1 where col1>=21 and col1<=30
Ö¸µ ......
ÏÖÔÚÑо¿¼òµ¥µÄ¶«Î÷£º
Student(S#,Sname,Sage,Ssex) ѧÉú±í
Course(C#,Cname,T#) ¿Î³Ì±í
SC(S#,C#,score) ³É¼¨±í
Teacher(T#,Tname) ½Ìʦ±í
ÎÊÌ⣺
SQL code:
1¡¢²éѯ¡°001¡±¿Î³Ì±È¡°0 ......