sql Ìõ¼þÅжÏÎÊÌâ
ÈçÏÂsqlÓï¾ä£¬ÈçºÎʵÏÖandºóÃæµÄÌõ¼þÅжÏ
select a.task_id,a.title,a.grade,a.school,
case when a.school=1 then 2 else cast((a.count1*100/c.count2) as dec(18,2)) end '±ÈÖµ——Èý¸öԵǼ¹ýµÄÓû§'
from
(select b.id as task_id,b.title as title,b.grade as grade,b.school as school ,sum(case when task_state=3 then 1 else 0 end)as count1 from ec_role_task c
join ec_role
a on a.id=c.role_id and del_state=0 and LAST_VISIT_TIME >=
convert(varchar(19),dateadd(month,-3,getdate()),21)
join ec_task
b on b.id=c.task_id and accept_again=0
group by b.title,b.grade,b.id,b.school
)a,
(select count(id) as count2 ,school from ec_role where del_state =0 and LAST_VISIT_TIME >=
convert(varchar(10),dateadd(month,-3,getdate()),21) and grade >= 25 and grade < 30 group by school )c ,ec_task t
where t.id=a.task_id and (case a.school =3 then a.school=c.school else a.school<>c.school end )
ºìÉ«²¿·ÖÊÇÓдíÎóµÄ²¿·Ö£¬´óϺÃǰïÎÒ¸Äһϣ¬¶Ô£¬¸øËùÓзÖ
ºìÉ«²»·ÖÉÙÁ˸ö when
select a.task_id,a.title,a.grade,a.school,
case when a.school=1 then 2 else cast((a.count1*100/c.count2) as dec(18,2)) end '±ÈÖµ——Èý¸öԵǼ¹ýµÄÓû§'
from
(select b.id as task_id,b.title as title,b.grade as grade,b.school as school ,sum(case when
Ïà¹ØÎÊ´ð£º
ÎÒÓжà¸ö±íA B C ½á¹¹ÊÇÒ»ÑùµÄ£¬¶¼ÓÐ2¸ö×Ö¶ÎnameºÍcontent,ÎÒÒªËÑË÷ËùÒÔ±íËùÓÐ×Ö¶ÎÖаüº¬¡°Öйú¡±µÄÄÚÈÝ Õâ¸öSQLÓï¾äÔõôд
ÈçºÎ½«¶à¸ö±íµÄ²éѯ½á¹ûÁ¬³ÉÒ»¸ö±í Õâ¸öSQLÓï¾äÔõôд ±íµÄ½á¹¹ÊÇÒ»ÑùµÄ
ÀýÈç£ ......
select convert(varchar(50),cast(convert(numeric(18,2),1275674000000/100000000)as real))+'ÒÚ'
select cast(convert(numeric(18,2),1275674000000/100000000)as real)
ΪʲôÉÏÒ»¸öÓÃvarcharת»»ºó¾ÍÖ»±£ÁôÁËÒ ......
type Exception report
message
description The server encountered an internal error () that prevented it from fulfilling this request.
exception
org.apache.jas ......
¿ÉÄÜÒòΪ¹¤×÷µÄÔÒò ½Ó´¥Êý¾Ý¿âÕâ¿é±È½ÏÉÙ£¬Ö®Ç°¶¼ÊÇ×ö³ÌÐòÕâ¿é£¬Êý¾Ý¿âÕâ¿é¶¼ÓÐרÃŵÄÈËÀ´×ö ·Ö¹¤¶¼ºÜÃ÷ϸ ËùÒÔ¶ÔÊý¾Ý¿âÕâÒ»¿éÍêÈ«²»Á˽⡣ǰ¶Îʱ¼ä È¥ÃæÊÔÁ˼¸¼Ò¹«Ë¾ ¼¸ºõ¶¼ÊÇÔÚÊý¾Ý¿âÕâ¿é¹ÒµôµÄ Á¬¸ö¼òµ¥µÄSQ ......
tab1 ×Ö¶Î:billdate,goodsid,incount,inmoney,outcount,outmoney,endprice,endcount,endamt
tab2 ×Ö¶Î:goodsid,goodskind£¨ÉÌÆ·ÀàÐÍ£©
tab3 ×Ö¶Î:goodskind£¨ÉÌÆ·ÀàÐÍ£©,kindname
½á¹û£º
µÃµ½ÉÌÆ·ÀàÐÍÔÚÒ»¶Îʱ¼ä ......