読者です 読者をやめる 読者になる 読者になる

落書きノート

ふと自分が気になった事を書いてます

SQLで問題を解く

SQL> select grade,losal * 0.99 N_LOSAL, hisal * 1.01 N_HISAL from salgrade;

     GRADE    N_LOSAL    N_HISAL
---------- ---------- ----------
     1   693      1212
     2    1188.99        1414
     3    1386.99        2020
     4    1980.99        3030
     5    2970.99    10098.99

SQL> select ename,sal from emp where sal >= 1300 and sal <= 2000;

ENAME         SAL
---------- ----------
ALLEN        1600
TURNER       1500
MILLER       1300

SQL> select ename,sal from emp where sal >= 1300 and sal <= 2000 order by sal;

ENAME         SAL
---------- ----------
MILLER       1300
TURNER       1500
ALLEN        1600

SQL> select ename,sal from emp where sal between 1300 and 2000 order by sal;

ENAME         SAL
---------- ----------
MILLER       1300
TURNER       1500
ALLEN        1600

SQL> select dname, loc from dept where loc not in('NEW YORK','DALLAS');

DNAME          LOC
-------------- -------------
SALES          CHICAGO
OPERATIONS     BOSTON

SQL> select count(*), avg(sal) from emp where deptno = 10;

  COUNT(*)   AVG(SAL)
---------- ----------
     3 2916.66667

SQL> select job from emp where job not like 'S%';

JOB
---------
CLERK
MANAGER
MANAGER
MANAGER
ANALYST
PRESIDENT
CLERK
CLERK
ANALYST
CLERK

10行が選択されました。