[쿼리문] select customer_id, purchase_amt, case when purchase_amt >= 500,000 then 'Y' else 'N' end as... [결과값] 이번에는 case when을 사용하여 좀 더 여러 조건을 설정해보자. 0~29만원 구매...
( SELECT * FROM MASTER..SYSPROCESSES P1 WHERE P.SPID = P1.BLOCKED AND P1.SPID <> P1.BLOCKED ) ) AND SPID > 50 AND SPID <> @@SPID ORDER BY CASE WHEN STATUS LIKE 'RUN%' THEN 0 ELSE 1 END , WAITTIME DESC , OPEN_TRAN DESC LOCK 걸린 SPID...
0 SELECT * FROM @UserTable WHERE 1=1 AND CASE WHEN @USER_TYPE_ADMIN = 1 THEN USER_TYPE ELSE 0 END = CASE WHEN @USER_TYPE_ADMIN = 1 THEN 0 ELSE 0 END --AND CASE WHEN @USER_TYPE_OPERATOR = 1 THEN USER_TYPE ELSE 0 END = CASE WHEN...
1500 0 1950 12 rows selected. SQL> SQL> select ename, deptno, sal, 2 CASE when deptno=10 then sal*0.1 3 when deptno=20 then sal*0.2 4 when deptno=30 then sal*0.3 5 else 0 6 END bonus 7 from emp;...
-
( SELECT A.* , CASE @SHOP WHEN SHOP_NO THEN CASE @MON WHEN MON THEN IF (@SALE_AMT > SALE_AMT, @ RANK := @ RANK + 1 , @ RANK ) ELSE @ RANK := 1 END ELSE @ RANK := 1 END AS RNK , @SHOP := SHOP_NO , @MON := MON , @SALE_AMT...
이것은 CASE WHEN expr1=expr2 THEN NULL ELSE expr1 END 와 같다. IFNULL > NULLIF > NULL 리턴 시 GROUP_CONCAT에서 포함되지 않는 듯하다. IFNULL인 경우 expr1 이나 expr2 인...
select left(s_trader.address,2) "지역별", sum(case when s_research.research_no is null then 0 else 1 end) "조사건수", sum(case when s_prosecution.research_no is null then 0 else 1 end) "적발건수", sum(case when s...
... NULL, `1` varchar(20) NOT NULL, `2` varchar(20) NOT NULL, `3` varchar(20) NOT NULL, `4` varchar(20) NOT NULL... SELECT GROUP_CONCAT(DISTINCT CONCAT( 'sum(case when map = ''', map, ''' then count else 0 end) AS `', map...
SELECT UPPER(c.table_name) REGIST_TBL_ID , UPPER(c.column_name) REGIST_COL_ID , CASE WHEN c.nullable = 'N' THEN '1' ELSE '0' END AS IS_NULLABLE , c.data_type DATA_TYPE , c.character_maximum_length CHAR_MAX...
... select case when (b.scoreTypeName like '%%' or b.scoreTypeSubname like '%%') and a.scoreTypeid != 1 then a.score else score end as EndScore from tbl_score a , tbl_scoretype b... scoreTypeid = 1 then 0 else a.score end ) as Sum_EndScore...
... 혹은 select count(*) as 접수 ,SUM(case when(adate-bdate)<=3 then 1 else 0 end)"3일" ,SUM(case when(adate-bdate)<=5 then 1 else 0 end)"5일" ,SUM(case when(adate-bdate)<=7 then 1 else 0 end)"7일" ,SUM(case when(adate-bdate)<=9 then...
... SUM(CASE WHEN month(date) = 4 THEN 1 ELSE 0 END) AS 01 제가 select 하는 부분에서 월별로 숫자를 집계하는 쿼리를 잤는데요 여기서 then 1 은 어떤걸 의미하는건가요??? date = 1 일때 then 1 else 0...