For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!
Interested in getting your voice heard by members of the Developer Marketing team at Oracle? Check out this post for AppDev or this post for AI focus group information.
SQL> select * from emp; EMPNO ENAME JOB MGR HIREDATE SAL COMM DEPTNO ---------- ---------- --------- ---------- --------- ---------- ---------- ---------- 7369 SMITH CLERK 7902 17-DEC-80 800 20 7499 ALLEN SALESMAN 7698 20-FEB-81 1600 300 30 7521 WARD SALESMAN 7698 22-FEB-81 1250 500 30 7566 JONES MANAGER 7839 02-APR-81 2975 20 7654 MARTIN SALESMAN 7698 28-SEP-81 1250 1400 30 7698 BLAKE MANAGER 7839 01-MAY-81 2850 30 7782 CLARK MANAGER 7839 09-JUN-81 2450 10 7788 SCOTT ANALYST 7566 19-APR-87 3000 20 7839 KING PRESIDENT 17-NOV-81 5000 10 7844 TURNER SALESMAN 7698 08-SEP-81 1500 0 30 7876 ADAMS CLERK 7788 23-MAY-87 1100 20 7900 JAMES CLERK 7698 03-DEC-81 950 30 7902 FORD ANALYST 7566 03-DEC-81 3000 20 7934 MILLER CLERK 7782 23-JAN-82 1300 10 14 rows selected. SQL> ed Wrote file afiedt.buf 1 select count(empno) as emps 2 , count(mgr) as mgrs 3 , sum(case when sal > 2000 then 1 else 0 end) as sals 4* from emp SQL> / EMPS MGRS SALS ---------- ---------- ---------- 14 13 6 SQL>
SELECT COUNT (empno) empno, COUNT (mgr) mgr, COUNT (CASE WHEN sal > 2000 THEN 1 END) sal FROM emp;
SQL> ed Wrote file afiedt.buf 1 select count(distinct empno) as emps 2 , count(distinct mgr) as mgrs 3 , count(distinct case when sal > 2000 then sal else null end) as sals 4* from emp SQL> / EMPS MGRS SALS ---------- ---------- ---------- 14 6 5 SQL>
SELECT COUNT (empno) AS empno_cnt , COUNT (mgr) AS mgr_cnt , COUNT ( CASE WHEN sal > 2000 THEN sal ELSE NULL -- This is the default, so you don't really need this line END ) AS sal_2000_cnt FROM emp;
select empno,mgr, (select count(sal) from emp where sal>2000) as sal from( select count(empno) as empno,count(mgr) as mgr from emp )
set @invent=(select count(inventoryReport)as invent from AdDashRoleProfile where inventoryReport != 1 and roleid=@roleid) set @development=(select count(development)as develop from AdDashRoleProfile where development != 1 and roleid=@roleid) set @Execution=(select count(Execution)as Exe from AdDashRoleProfile where Execution != 1 and roleid=@roleid) insert into @tempRole(inventoryReport,development,Execution) values(@invent,@development,@Execution) select * from @tempRole
SELECT (SELECT COUNT (inventoryreport) FROM addashroleprofile WHERE inventoryreport != 1 AND roleid = v_roleid) inventoryreport, (SELECT COUNT (development) FROM addashroleprofile WHERE development != 1 AND roleid = v_roleid) development, (SELECT COUNT (execution) FROM addashroleprofile WHERE execution != 1 AND roleid = v_roleid) execution FROM DUAL;
/* Formatted on 2009/04/08 09:22 (Formatter Plus v4.8.8) */ SELECT COUNT (CASE WHEN inventoryreport != 1 AND roleid = v_roleid THEN inventoryreport END ) inventoryreport, COUNT (CASE WHEN development != 1 AND roleid = v_roleid THEN development END ) development, COUNT (CASE WHEN execution != 1 AND roleid = v_roleid THEN execution END ) execution FROM addashroleprofile;
SELECT COUNT(CASE WHEN inventoryreport != 1 AND roleid = v_roleid THEN inventoryreport END) inventoryreport ,COUNT(CASE WHEN development != 1 AND roleid = v_roleid THEN development END) development ,COUNT(CASE WHEN execution != 1 AND roleid = v_roleid THEN execution END) execution FROM addashroleprofile;
SELECT COUNT(CASE WHEN inventoryreport != 1 THEN inventoryreport END) inventoryreport, COUNT(CASE WHEN development != 1 THEN development END) development, COUNT(CASE WHEN execution != 1 THEN execution END) execution FROM addashroleprofile WHERE roleid = v_roleid;
select count(nullIF(inventoryreport,1)) inventoryreport count(nullIF(development,1)) development count(nullIF(execution,1)) execution from addashroleprofile WHERE roleid = v_roleid;