»Ë»Ñ Æ÷·³
°³¹ßÀÚÆ÷·³ ÀÔ´Ï´Ù.
  • ºÏ¸¶Å© ¾ÆÀÌÄÜ

SQL Äõ¸®¹® ¹®Àǵ帳´Ï´Ù.1

¾Æ·¡ Äõ¸®¹® ½ÇÇà½Ã °á°ú°ªÀÌ ¾Æ·¡¿Í °°ÀÌ Ãâ·Â°ªÀ» ¿ìÃø°ú °°ÀÌ º¯°æÇÏ°í ½Í½À´Ï´Ù.
 
B±×·ì¿¡¼­ Á¶°ÇÀ» º¯°æÇÏ´Ï °°Àº°ªÀÌ µé¾î°¡ Ãâ·Â°ªÀÌ µ¿ÀÏÇÏ°Ô ÂïÈ÷°í ¹æ¹ýÀ» ¸øã°Ú³×¿ä..
 
Ȥ½Ã ¾Æ½Ã´ÂºÐ ÀÖÀ»±î¿ä?
 
select BIZ_CODE, A.m2 as mm, A.dd as dd, 
case when bad_m1 = 0 then 100 when PROD_M1 is null then 0 else (1 - (bad_m1 / nullif (PROD_M1 + BAD_M1, 0))) * 100 end as val1
from ((
select distinct YYYYMM, M2, dd
from aaaa
where yyyy = '2016' and yyyymm = '201612') A left join (
select yyyymm, dd, BIZ_CODE as BIZ_CODE, sum(prod_m2) as prod_m1, sum(bad_m2) as bad_m1
from bbbb
where YYYY = '2016' and YYYYMM <= '201612'
and biz_code like '%'
group by yyyymm, dd, BIZ_CODE) B on A.dd = B.dd
and a.YYYYMM = b.YYYYMM)
order by mm, dd
 

20161213154102_uenhftcd.jpg

 

0
ÃßõÇϱ⠴ٸ¥ÀÇ°ß 0
|
°øÀ¯¹öÆ°
÷ºÎÆÄÀÏ
  • 1212.jpg

´Ù¸¥ÀÇ°ß 0 Ãßõ 0 º½-º½
  • ¾Ë¸² ¿å¼³, »óó ÁÙ ¼ö ÀÖ´Â ¾ÇÇÃÀº »ï°¡ÁÖ¼¼¿ä.
©¹æ »çÁø  
¡â ÀÌÀü±Û¡ä ´ÙÀ½±Û