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Ô ¶þÔ ÈýÔ ËÄÔ ÎåÔ ÁùÔ ÆßÔ 
Ïà¹ØÎÊ´ð£º
with adod_dict do
begin
close;
commandtext:='select bgqxcode,count(*) wjsl from wscl_wsda_file where wjnd=:tnd group by bgqxcode'; ......
±íÖа´datadate,tradeidΪÖ÷¼ü£¬Ò²¾ÍÊÇ˵tradeid»áÖØ¸´³öÏÖÔÚ²»Í¬ÌìÖУ¬Í¬Ò»ÌìµÄtradeidÊDz»Í¬µÄ¡£ÏÖÔÚÎÒÏ£Íûȡһ¶Îʱ¼ä·¶Î§ÄÚ²»Öظ´µÄtradeid£¬ÇÒֻҪÿ¸ötradeidµÄ×îºóÒ»´Î³öÏÖµÄÄÇÌõ¡£sqlÓï¾ä¸ÃÔõôд
£º ......
ÎÒÓõÄÊÇmysql5.1£¬Êý¾Ý¿â×Ö·û¼¯Îªutf8
ͨ¹ýdosÃüÁîÐе¼ÈëSQLÎļþ ³ö´í£¬ÎÞ·¨µ¼Èë¡£
½«SQLÎļþÖеÄÊý¾ÝÈ«²¿Ê¹ÓÃÓ¢ÎÄ ¿ÉÒÔµ¼Èë
ÇëÎÊÎÊÌâÔÚÄÄ£¿
×°¸öÖÐÎÄÈí¼þ¼´¿É.
ºÜ¶àÄêÒÔǰ,Óùý¸öÒ»¸ ......
´ó¼Ò°ïæ¿´¿´Õâ2¸ösqlÓï¾äÄĸö²éѯµÄËٶȸü¿ìµã¡£Ð»Ð»°ïæ¡£±È½Ï׿±¡£ÔÚ×öÐÔÄܲâÊÔ¡£
select * from
±íA LEFT OUTER JOIN ±íB ON (±íA.id || ' ' =±íB.id) ,±íC , ±íD, ±íE
WhereÆäËûÌõ¼þ
select * ......
ÓÐÁ½ÌõSQLÓï¾ä£¨Ò»¸ö¿ªÊ¼Ò»¸ö½áÊø£©£¬ÎÒÏëÔÚ×ÀÃæÉÏÖ´ÐУ¬¹âÌý˵Ҫ×ö¸ö´°Ì廹ÊǿؼþµÄ£¬ÕâÔõô×ö£¿ÇóÀÏʦÃǰïæ£¬ÏÈлл£¡£¡£¡£¡
ʲôÒâ˼£¬Â¥Ö÷˵Çå³þЩ
...ÊÇѽ£¬ÏÈ˵Çå³þÂï
£¿
ÎÒµÄÒâ˼ÊÇ˵ÔÚ×ÀÃæÉÏ×ö¸ö ......