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

¶àÌõ¼þÇóºÍSqlÓï¾ä

±í¸ñ½á¹¹ account_id, account_name, sellingprice, factory_id  ÀýÈçÊý¾ÝÈçÏ£º
account_id account_name sellingprice factory_id
001 stephe 200 aa
001 stephe 100 bb
002 adrian 200 aa
002 adrian 300 bb
002 adrian 100 cc
003 nweton 250 aa
003 nweton 300 cc

ÏÖÔÚÏëͳ¼Æ½á¹ûÈçÏ£¬account_id, account_name,sum(sellingprice_factory_aa),sum(sellingprice_factory_bb),sum(sellingprice_factory_cc)
Çë¸ßÊÖ°ïæָµãÏÂÈçºÎдsql´úÂ룬лл¡£


SQL code:
select account_id, account_name,
sum(case factory_id when 'aa' then sellingprice end) as sellingprice_factory_aa,
sum(case factory_id when 'bb' then sellingprice end) as sellingprice_factory_bb,
sum(case factory_id when 'cc' then sellingprice end) as sellingprice_factory_cc
from ±í¸ñ
group by account_id, account_name



SQL code:
SELECT account_id ,account_name ,
[aa]=sum(case factory_id when 'aa' then sellingprice else 0 end),
[bb]=sum(case factory_id when 'bb' then sellingprice else 0 end),
[cc]=sum(case factory_id when 'bb' then sellingprice else 0 end)
from TableName
GROUP BY account_id,account_name


¸üÕý£ºSQL code



Code highlighting produced by Actipro CodeH


Ïà¹ØÎÊ´ð£º

csvÎļþת»»³Ésqlµ¼Èëµ½Êý¾Ý¿â£¬Ã»ÓÐÊý¾ÝΪºÎ£¿

Ö´ÐеÄ˳Ðò£º
1£©Îļþä¯ÀÀ¿ò£¨Ñ¡ÔñÎļþʹÓã©
Ñ¡ÔñºÃÎļþºó
µã»÷Ò»¸öµ¼Èë°´Å¥µÄʱºò £¬°ÑÉÏÃæÉÏ´«¿òÀïµÄcsvÎļþÒÔÒ»¸öIDΪÎļþÃû£¬ÉÏ´«µ½**/**Îļþ¼ÐÏÂ
2£©¶ÁÈ¡Õâ¸öÎļþ¼ÐϵÄcsvµÄÎļþ£¬×ª»»³Ésql
3 ......

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

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

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

jspÁ´½Ósql2000µÄÒÉÎÊ£¿



type Exception report


message

description The server encountered an internal error () that prevented it from fulfilling this request.

exception

org.apache.jas ......

sql ½ØÈ¡×Ö·û´®

ÎÒÒªµÃµ½Ò»¸ö×Ö·û´®È磺
sdfk|||sgts
sdfsfd|||rgreg
wrfw|||sefw
¾ÍÊÇÒªµÃµ½|||ºóÃæµÄ×Ö·û´®£¬ÓÐʲôº¯ÊýÂð£¿ÔõôÓÃÄØ£¿Ð»Ð»£¡
SQL code:
select
right(col,len(col)-charindex('|||',col)-2)
f ......

sql º¯ÊýÎÊÌâ - MS-SQL Server / Ó¦ÓÃʵÀý

sqlÎÒÏëµÃµ½Ò»×Ö·û´®Îª:
sldkf|||sdeww
erkv|||rltdk
jemcl|||ligf
¾ÍÊÇ|||ºóÃæµÄ×Ö·ûÓÐʲôº¯ÊýÄܵõ½Âð£¿ÊÇÔÚsqlÓï¾äдµÄ£¬²»ÊÇÔÚÒ³ÃæÐ´µÄ£¬ÄÇλ¸ßÊÖÀ´Ö¸½ÌÏ£¬ÐÂÊÖ£¬Ð»Ð»
ÔνñÌì²»ÊÇдÁËô

select parsen ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØÍ¼ | ¸ÓICP±¸09004571ºÅ