Advertisement
ma39isy

Untitled

Mar 28th, 2024
1,110
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. SELECT
  2.                     STUDENTSCHOOLYEAR,
  3.     ACTIVE,
  4.     GRADUATED,
  5.     PASSEDAWAY,
  6.     DROPOUT,
  7.     RESIGN,
  8.     UNKNOWN,
  9.     LEAVE,
  10.     NONACTIVE,
  11.     COUNT(*)
  12.                     AS TOTAL
  13. FROM
  14.     MASTERDATA.STUDENT
  15. JOIN MASTERDATA.STUDYPROGRAM
  16.         USING (STUDYPROGRAMID)
  17. LEFT JOIN
  18.                     (
  19.     SELECT
  20.         STUDENTSCHOOLYEAR,
  21.         COUNT(*) ACTIVE
  22.     FROM
  23.         MASTERDATA.STUDENT
  24.     JOIN MASTERDATA.STUDYPROGRAM
  25.             USING (STUDYPROGRAMID)
  26.     WHERE
  27.         STUDENTTYPEID =
  28.                     '1'
  29.     GROUP BY
  30.         (STUDENTSCHOOLYEAR))
  31.         USING (STUDENTSCHOOLYEAR)
  32. LEFT JOIN
  33.                     (
  34.     SELECT
  35.         STUDENTSCHOOLYEAR,
  36.         COUNT(*) PASSEDAWAY
  37.     FROM
  38.         MASTERDATA.STUDENT
  39.     JOIN MASTERDATA.STUDYPROGRAM
  40.             USING (STUDYPROGRAMID)
  41.     WHERE
  42.         STUDENTTYPEID =
  43.                     '5'
  44.     GROUP BY
  45.         (STUDENTSCHOOLYEAR))
  46.         USING (STUDENTSCHOOLYEAR)
  47. LEFT JOIN
  48.                     (
  49.     SELECT
  50.         STUDENTSCHOOLYEAR,
  51.         COUNT(*) GRADUATED
  52.     FROM
  53.         MASTERDATA.STUDENT
  54.     JOIN MASTERDATA.STUDYPROGRAM
  55.             USING (STUDYPROGRAMID)
  56.     WHERE
  57.         STUDENTTYPEID =
  58.                     '2'
  59.     GROUP BY
  60.         (STUDENTSCHOOLYEAR))
  61.         USING (STUDENTSCHOOLYEAR)
  62. LEFT JOIN
  63.                     (
  64.     SELECT
  65.         STUDENTSCHOOLYEAR,
  66.         COUNT(*) DROPOUT
  67.     FROM
  68.         MASTERDATA.STUDENT
  69.     JOIN MASTERDATA.STUDYPROGRAM
  70.             USING (STUDYPROGRAMID)
  71.     WHERE
  72.         STUDENTTYPEID =
  73.                     '6'
  74.     GROUP BY
  75.         (STUDENTSCHOOLYEAR))
  76.         USING (STUDENTSCHOOLYEAR)
  77. LEFT JOIN
  78.                     (
  79.     SELECT
  80.         STUDENTSCHOOLYEAR,
  81.         COUNT(*) UNKNOWN
  82.     FROM
  83.         MASTERDATA.STUDENT
  84.     JOIN MASTERDATA.STUDYPROGRAM
  85.             USING (STUDYPROGRAMID)
  86.     WHERE
  87.         (STUDENTTYPEID IN ('7', '9', '5')
  88.             OR STUDENTTYPEID IS NULL)
  89.     GROUP BY
  90.         (STUDENTSCHOOLYEAR))
  91.         USING (STUDENTSCHOOLYEAR)
  92. LEFT JOIN
  93.                     (
  94.     SELECT
  95.         STUDENTSCHOOLYEAR,
  96.         COUNT(*) RESIGN
  97.     FROM
  98.         MASTERDATA.STUDENT
  99.     JOIN MASTERDATA.STUDYPROGRAM
  100.             USING (STUDYPROGRAMID)
  101.     WHERE
  102.         STUDENTTYPEID =
  103.                     '3'
  104.     GROUP BY
  105.         (STUDENTSCHOOLYEAR))
  106.         USING (STUDENTSCHOOLYEAR)
  107. LEFT JOIN
  108.                     (
  109.     SELECT
  110.         STUDENTSCHOOLYEAR,
  111.         COUNT(*) LEAVE
  112.     FROM
  113.         MASTERDATA.STUDENT
  114.     JOIN MASTERDATA.STUDYPROGRAM
  115.             USING (STUDYPROGRAMID)
  116.     WHERE
  117.         STUDENTTYPEID =
  118.                     '8'
  119.     GROUP BY
  120.         (STUDENTSCHOOLYEAR))
  121.         USING (STUDENTSCHOOLYEAR)
  122. LEFT JOIN
  123.                     (
  124.     SELECT
  125.         STUDENTSCHOOLYEAR,
  126.         COUNT(*) NONACTIVE
  127.     FROM
  128.         MASTERDATA.STUDENT
  129.     JOIN MASTERDATA.STUDYPROGRAM
  130.             USING (STUDYPROGRAMID)
  131.     WHERE
  132.         STUDENTTYPEID IN ('10')
  133.     GROUP BY
  134.         (STUDENTSCHOOLYEAR))
  135.         USING (STUDENTSCHOOLYEAR)
  136. WHERE
  137.     1 = 1
  138. GROUP BY
  139.                     (STUDENTSCHOOLYEAR,
  140.     ACTIVE,
  141.     GRADUATED,
  142.     PASSEDAWAY,
  143.     DROPOUT,
  144.     RESIGN,
  145.     UNKNOWN,
  146.     LEAVE,
  147.     NONACTIVE)
  148. ORDER BY
  149.     STUDENTSCHOOLYEAR
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement