Advertisement
szubert

Untitled

Jan 24th, 2017
214
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 2.29 KB | None | 0 0
  1. --1
  2. select emp_no from employee where emp_no in (select emp_no from works_on where project_no in (select project_no from project where project_no = 'p2' and emp_no <10000))
  3.  
  4. --2
  5. select emp_no from works_on where enter_date < '2007-01-01' and enter_date < '2007-12-31'
  6.  
  7. --3
  8. select emp_no, emp_lname from employee where emp_fname like '%t%t%'
  9.  
  10. --4
  11. select emp_no from employee where dept_no in(select dept_no from department where location = 'Seattle')
  12. --5
  13. If the grouping column contains a null value,that row becomes a group in the results. If the grouping column contains more than one null value, the null values are put into a single group.
  14.  
  15. --6
  16. The COUNT(column) function returns the number of values (NULL values will not be counted) of the specified column
  17. The COUNT(*) function returns the number of records in a table
  18.  
  19. --7
  20. select max(emp_no) from employee
  21.  
  22. --8
  23. select job from works_on group by job having count(job) > 2
  24.  
  25. --9
  26. select emp_no,job from works_on where project_no in(select project_no from project where project_name='Gemini')
  27.  
  28. --10
  29. select emp_fname, emp_lname from employee where dept_no in(select dept_no from department where dept_name = 'Research' or dept_name = 'Accounting')
  30.  
  31. --11
  32. select enter_date from works_on where emp_no in(select emp_no from employee where dept_no in (select dept_no from department where job='clerk' and dept_no='d1'))
  33.  
  34. --13
  35. select emp_fname, emp_lname from employee where emp_no in (select emp_no from works_on where project_no in (select project_no from project where project_name='Mercury' and job='manager'))
  36.  
  37. --14
  38. select emp_no from employee where dept_no in (select dept_no from department where dept_name='marketing')
  39. select emp_no from works_on where emp_no in (select emp_no from employee where dept_no in (select dept_no from department where dept_name='marketing'))
  40.  
  41. --15
  42. select project_no, project_name into #project_temp from project
  43. select * from #project_temp
  44. CREATE TABLE #project_temp(project_no CHAR(4),
  45.                        project_name CHAR(15),
  46.                         budget FLOAT)
  47. Temporary tables are  used to store intermediate calculations in a complex series of CREATE or UPDATE queries that produce some sort of analysis result. Temporary tables are also sometimes used to increase performance, in certain situations.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement