Advertisement
absorr

final output 2

Mar 4th, 2016
102
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.21 KB | None | 0 0
  1. SQL> SELECT s.*, a.*, d.* FROM stephensow1_final_Student s,
  2. 2 stephensow1_final_Advisor a, stephensow1_final_Dept d
  3. 3 WHERE STU_NUM = 123984 AND s.Dept_Code = d.Dept_Code
  4. 4 AND s.Advisor_ID = a.Advisor_ID AND a.Dept_Code = d.Dept_Code;
  5.  
  6. STU_NU STU_LNAME STU_MAJOR STU_GPA STU_HOURS STU_CLASS ADVIS
  7. ------ ---------------- ---------------- ---------- ---------- ---------- -----
  8. DEPT_ ADVIS ADVISOR_LNAME ADVI ADVISOR_BLDG
  9. ----- ----- ---------------- ---- --------------------------------
  10. ADVISOR_PHONE DEPT_ DEPT_ DEPT_NAME DEPT_PHONE
  11. ---------------- ----- ----- -------------------------------- ----------------
  12. COLLEGE_NAME
  13. --------------------------------
  14. 123984 Thomas CIT 2.5 93 Senior 005
  15. CS 005 Lewis 5132 Griffin
  16. 1603 CS CS Computer Science 5234
  17. Informatics
  18.  
  19.  
  20. SQL>
  21. SQL> SELECT COUNT(s.Stu_Major) AS Num_Students, s.Stu_Major, d.College_Name
  22. 2 FROM stephensow1_final_Student s, stephensow1_final_Dept d
  23. 3 WHERE s.Dept_Code = d.Dept_Code
  24. 4 GROUP BY Stu_Major, College_Name;
  25.  
  26. NUM_STUDENTS STU_MAJOR COLLEGE_NAME
  27. ------------ ---------------- --------------------------------
  28. 2 Marketing Business Admin
  29. 1 Statistics Arts & Sciences
  30. 2 BIS Informatics
  31. 2 Accounting Business Admin
  32. 1 CIT Informatics
  33.  
  34. SQL>
  35. SQL> SELECT d.Dept_Name, COUNT(CASE s.Stu_Class WHEN 'Freshman' then 1 else null end) AS Num_Fresh,
  36. 2 COUNT(CASE s.Stu_Class WHEN 'Sophomore' then 1 else null end) AS Num_Soph,
  37. 3 COUNT(CASE s.Stu_Class WHEN 'Junior' then 1 else null end) AS Num_Junior,
  38. 4 COUNT(CASE s.Stu_Class WHEN 'Senior' then 1 else null end) AS Num_Senior
  39. 5 FROM stephensow1_final_Student s, stephensow1_final_Dept d
  40. 6 WHERE s.Dept_Code = d.Dept_Code
  41. 7 GROUP BY Dept_Name;
  42.  
  43. DEPT_NAME NUM_FRESH NUM_SOPH NUM_JUNIOR NUM_SENIOR
  44. -------------------------------- ---------- ---------- ---------- ----------
  45. Accounting 0 1 1 0
  46. Mathematics 0 0 1 0
  47. Computer Science 0 0 0 1
  48. Business Informatics 0 0 2 0
  49. Marketing 0 0 0 2
  50.  
  51. SQL>
  52. SQL> SELECT s.Stu_Num, s.Stu_LName, s.Stu_Major, d.Dept_Name, a.Advisor_LName
  53. 2 FROM stephensow1_final_Student s, stephensow1_final_Dept d,
  54. 3 stephensow1_final_Advisor a WHERE s.Dept_Code = d.Dept_Code
  55. 4 AND s.Advisor_ID = a.Advisor_ID AND a.Dept_Code = d.Dept_Code
  56. 5 AND s.Stu_GPA > 3.5 AND d.College_Name LIKE 'Business Admin'
  57. 6 ORDER BY s.Stu_GPA ASC;
  58.  
  59. STU_NU STU_LNAME STU_MAJOR DEPT_NAME
  60. ------ ---------------- ---------------- --------------------------------
  61. ADVISOR_LNAME
  62. ----------------
  63. 211343 Stephanos Accounting Accounting
  64. Grastand
  65.  
  66.  
  67. SQL>
  68. SQL> SELECT s.Stu_LName, s.Stu_Major, a.Advisor_LName
  69. 2 FROM stephensow1_final_Student s, stephensow1_final_Advisor a
  70. 3 WHERE s.Advisor_ID = a.Advisor_ID;
  71.  
  72. STU_LNAME STU_MAJOR ADVISOR_LNAME
  73. ---------------- ---------------- ----------------
  74. Stephanos Accounting Grastand
  75. Smith Accounting Grastand
  76. Jones Marketing Gentry
  77. Ortiz Marketing Tillery
  78. McKulski Statistics Chen
  79. Thomas CIT Lewis
  80. Thompson BIS Zang
  81. Meyers BIS Goh
  82.  
  83. 8 rows selected.
  84.  
  85. SQL>
  86. SQL> SELECT d.College_Name, COUNT(CASE WHEN s.Stu_GPA >= 3.5 then 1 else null end) AS Num_DeansList
  87. 2 FROM stephensow1_final_Student s, stephensow1_final_Dept d
  88. 3 WHERE s.Dept_Code = d.Dept_Code
  89. 4 GROUP BY College_Name;
  90.  
  91. COLLEGE_NAME NUM_DEANSLIST
  92. -------------------------------- -------------
  93. Business Admin 1
  94. Informatics 0
  95. Arts & Sciences 1
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement