pan7nikt

SQL_Kwerendy_apin

Nov 29th, 2021
1,060
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. --1
  2. SELECT`DEPTNO`,`ENAME`,`MGR` FROM `emp`;
  3.  
  4. --2
  5. SELECT * FROM `emp`;
  6.  
  7. --3
  8. SELECT `ENAME`,`SAL`*12 AS roczna FROM `emp`;
  9.  
  10. --4
  11. SELECT `ENAME`,(`SAL`+250)*12 AS roczna FROM `emp`;
  12.  
  13. --5
  14. SELECT `SAL`*12 AS Roczna FROM `emp`;
  15.  
  16. --6
  17. SELECT `SAL`*12 AS `Placa Roczna` FROM `emp`;
  18.  
  19. --7
  20. SELECT CONCAT(`EMPNO`, ' ', `ENAME`) AS zatrudniony FROM `emp`;
  21.  
  22. --8
  23. SELECT CONCAT(`EMPNO`, ' ', `ENAME`, ' ', 'Pracownik pracuje w dziale nr ') AS zatrudniony, `DEPTNO` AS dzial FROM `emp`;
  24.  
  25. --9
  26. SELECT `SAL`*12 + IF(`COMM` IS NOT NULL, `COMM`, 0) AS roczna FROM `emp`;
  27.  
  28. --10
  29. SELECT `DEPTNO` FROM `emp`;
  30.  
  31. --11
  32. SELECT DISTINCT `DEPTNO` FROM `emp`;
  33.  
  34. --12
  35. SELECT DISTINCT `deptno`,`job` FROM `emp`;
  36.  
  37. --13
  38. SELECT * FROM `emp` ORDER BY `ENAME` ASC;
  39.  
  40. --14
  41. SELECT * FROM `emp` ORDER BY `HIREDATE` DESC;
  42.  
  43. --15
  44. SELECT * FROM `emp` ORDER BY `DEPTNO` ASC, `SAL` DESC;
  45.  
  46. --16
  47. SELECT `ENAME`, `EMPNO`, `JOB`, `SAL`, `DEPTNO` FROM `emp` WHERE `JOB`='CLERK';
  48.  
  49. --17
  50. SELECT `DNAME`, `DEPTNO`FROM `DEPT` WHERE `DEPTNO`>20;
  51.  
  52. --18
  53.  
  54.  
  55. --19
  56. SELECT * FROM `emp` WHERE `SAL` BETWEEN 1000 AND 2000;
  57.  
  58. --20
  59. SELECT * FROM `emp` WHERE `MGR` = 7902 OR `MGR` = 7566 OR `MGR` = 7788;
  60.  
  61. --21
  62. SELECT * FROM `emp` WHERE LEFT(`ENAME`,1) = 'S';
  63.  
  64. --22
  65. SELECT * FROM `emp` WHERE CHAR_LENGTH(`ENAME`) = 4;
  66.  
  67. --23
  68. SELECT * FROM `emp` WHERE `MGR` IS NULL;
  69.  
  70. --24
  71. --ewentualnie NOT BETWEEN
  72. SELECT * FROM `emp` WHERE `SAL` < 1000 OR `SAL` > 2000;
  73.  
  74. --25
  75. SELECT * FROM `emp` WHERE LEFT(`ENAME`, 1) != 'M';
  76.  
  77. --26
  78. SELECT * FROM `emp` WHERE `MGR` IS NOT NULL;
  79.  
  80. --27
  81. SELECT * FROM `emp` WHERE `JOB` = 'CLERK' AND `SAL` BETWEEN 1000 AND 2000;
  82.  
  83. --28
  84. SELECT * FROM `emp` WHERE `JOB` = 'CLERK' OR `SAL` BETWEEN 1000 AND 2000;
  85.  
  86. --29
  87. SELECT * FROM `emp` WHERE `JOB` = 'MANAGER' AND `SAL` > 1500 OR `JOB` = 'SALESMAN';
  88.  
  89. --30
  90. SELECT * FROM `emp` WHERE `JOB` = 'MANAGER' OR `JOB` = 'SALESMAN' AND `SAL` > 1500;
  91.  
  92. --31
  93. SELECT * FROM `emp` WHERE `JOB` = 'MANAGER' OR `JOB` = 'CLERK' AND `DEPTNO` = 10;
  94.  
  95. --32
  96. SELECT * FROM `SALGRADE`;
  97.  
  98. --33
  99. SELECT * FROM `DEPT`;
  100.  
  101. --34
  102. SELECT * FROM
RAW Paste Data