안녕하세요?
case( case( case(case( ....
이런 방식으로 조건을 걸어서 쿼리를 하여 100... 이상 할려면 어떻게 해야 합니까?
도와 주세요...
참고 문서나 방법등을 알고 싶습니다.
case 을 여러개 쓰시겠다는건지 아니면 case문 하나에 case를 여러개 쓰시겠다는 건지 질문의 의도를 정확히 모르겠네요
case문을 이용해서 여러개의 값을 한줄로 나오게 한다면 이런식으로 하면 될겁니다. 이게 답변이 될런지 모르겟네요 수고
select a.line_code, c.nacf_name, a.name chulhaju_name, d.item itempum, d.name itempum_name, a.item, b.name item_name, sum(case when a.unit_count < 10 then (a.quantity) else 0 end) as qty10, sum(case when unit_count >= 10 and a.unit_count <= 15 then (a.quantity) else 0 end) as qty15, sum(case when unit_count >= 16 and a.unit_count <= 20 then (a.quantity) else 0 end) as qty20, sum(case when unit_count >= 21 and a.unit_count <= 25 then (a.quantity) else 0 end) as qty22, sum(case when unit_count >= 26 and a.unit_count <= 30 then (a.quantity) else 0 end) as qty30, sum(case when unit_count >= 31 then (a.quantity) else 0 end) as qty40,
sum(case when a.unit_count < 10 then (a.amt) else 0 end) as amt10, sum(case when unit_count >= 10 and a.unit_count <= 15 then (a.amt) else 0 end) as amt15, sum(case when unit_count >= 16 and a.unit_count <= 20 then (a.amt) else 0 end) as amt20, sum(case when unit_count >= 21 and a.unit_count <= 25 then (a.amt) else 0 end) as amt22, sum(case when unit_count >= 26 and a.unit_count <= 30 then (a.amt) else 0 end) as amt30, sum(case when unit_count >= 31 then (a.amt) else 0 end) as amt40 from sales a,goods b, customer c, goods d where a.item = b.item and substring(b.item,1,2) + '00' = d.item and a.line_code = c.code and a.weight = 15 and a.sale_date between '2003-09-01' and '2003-09-31'and a.item = 1030group by a.line_code, a.name,c.nacf_name, d.item, d.name, a.item, b.nameorder by a.line_code
먼저 답변 감사합니다..
제가 요구하는건 중첩을 예기합니다.
case(case ...then... else ...)...then .... else...
이런식으로 10단계이상의 깊이로 들어가서 검색을 가능하게 하고 싶습니다.