Advertisement
Anton0093

5_1

Apr 13th, 2021
787
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. select distinct
  2. сл.ЛАБОРАТОРИЯ_ИД,  
  3. лаб.НАИМЕНОВАНИЕ,  
  4.  
  5. SUM(  
  6. CASE  
  7.     WHEN (to_char(сл.ДЕНЬ_РОЖДЕНИЯ, 'MM') = '03') or  
  8.     (to_char(сл.ДЕНЬ_РОЖДЕНИЯ, 'MM') = '04') or  
  9.     (to_char(сл.ДЕНЬ_РОЖДЕНИЯ, 'MM') = '05')  
  10.     THEN 1  
  11.     ELSE 0  
  12. END),  
  13.  
  14. SUM(  
  15. CASE  
  16.     WHEN (to_char(сл.ДЕНЬ_РОЖДЕНИЯ, 'MM') = '06') or  
  17.     (to_char(сл.ДЕНЬ_РОЖДЕНИЯ, 'MM') = '07') or  
  18.     (to_char(сл.ДЕНЬ_РОЖДЕНИЯ, 'MM') = '08')  
  19.     THEN 1  
  20.     ELSE 0  
  21. END),  
  22.  
  23. SUM(  
  24. CASE  
  25.     WHEN (to_char(сл.ДЕНЬ_РОЖДЕНИЯ, 'MM') = '09') or  
  26.     (to_char(сл.ДЕНЬ_РОЖДЕНИЯ, 'MM') = '10') or  
  27.     (to_char(сл.ДЕНЬ_РОЖДЕНИЯ, 'MM') = '11')  
  28.     THEN 1  
  29.     ELSE 0  
  30.     END),  
  31.  
  32. SUM(  
  33. CASE  
  34.     WHEN (to_char(сл.ДЕНЬ_РОЖДЕНИЯ, 'MM') = '12') or  
  35.     (to_char(сл.ДЕНЬ_РОЖДЕНИЯ, 'MM') = '01') or  
  36.     (to_char(сл.ДЕНЬ_РОЖДЕНИЯ, 'MM') = '02')  
  37.     THEN 1  
  38.     ELSE 0  
  39.     END),  
  40.  
  41. date_part('year',age(сл.ДЕНЬ_РОЖДЕНИЯ::date))  
  42.  
  43. from s_ЛАБОРАТОРИИ лаб  
  44.  
  45. JOIN s_СЛУЖАЩИЕ сл  
  46. ON лаб.ИД = сл.ЛАБОРАТОРИЯ_ИД
  47.  
  48. group by  сл.ИД, лаб.НАИМЕНОВАНИЕ
  49.  
  50.  
  51.  
  52.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement