Andriej91

Untitled

Sep 24th, 2021 (edited)
205
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. SELECT
  2.  
  3. #2021
  4. (SELECT COUNT(*) FROM (SELECT id FROM sorga_ptchr_archive._d_Czlonkowie WHERE                                   `historyStartDate` <= '2021-08-31' AND (`historyEndDate` >= '2021-08-31' OR `historyEndDate` IS NULL) GROUP BY id) AS x) AS 'Ilość członków na dzień 2021-08-31',
  5. (SELECT COUNT(*) FROM (SELECT id FROM sorga_ptchr_archive._d_Czlonkowie WHERE RIGHT(Imie, 1)='a' AND            `historyStartDate` <= '2021-08-31' AND (`historyEndDate` >= '2021-08-31' OR `historyEndDate` IS NULL) GROUP BY id) AS x) AS 'Ilość kobiet na dzień 2021-08-31',
  6. (SELECT COUNT(*) FROM (SELECT id FROM sorga_ptchr_archive._d_Czlonkowie WHERE RIGHT(Imie, 1)!='a' AND           `historyStartDate` <= '2021-08-31' AND (`historyEndDate` >= '2021-08-31' OR `historyEndDate` IS NULL) GROUP BY id) AS x) AS 'Ilość mężczyzn na dzień 2021-08-31',
  7. (SELECT COUNT(*) FROM (SELECT id FROM sorga_ptchr_archive._d_Czlonkowie WHERE Specjalizacja IS NOT NULL AND     `historyStartDate` <= '2021-08-31' AND (`historyEndDate` >= '2021-08-31' OR `historyEndDate` IS NULL) GROUP BY id) AS x) AS 'Ilość osób ze specjalizacją na dzień 2021-08-31',
  8. (SELECT COUNT(*) FROM (SELECT id FROM sorga_ptchr_archive._d_Czlonkowie WHERE Specjalizacja IS NULL AND         `historyStartDate` <= '2021-08-31' AND (`historyEndDate` >= '2021-08-31' OR `historyEndDate` IS NULL) GROUP BY id) AS x) AS 'Ilość osób bez specjalizacji na dzień 2021-08-31',
  9. (SELECT COUNT(*) FROM (SELECT id FROM sorga_ptchr_archive._d_Czlonkowie WHERE Zawod = 5 AND                     `historyStartDate` <= '2021-08-31' AND (`historyEndDate` >= '2021-08-31' OR `historyEndDate` IS NULL) GROUP BY id) AS x) AS 'Ilość lekarzy na dzień 2021-08-31',
  10. (SELECT COUNT(*) FROM (SELECT id FROM sorga_ptchr_archive._d_Czlonkowie WHERE Zawod = 8 AND                     `historyStartDate` <= '2021-08-31' AND (`historyEndDate` >= '2021-08-31' OR `historyEndDate` IS NULL) GROUP BY id) AS x) AS 'Ilość fizjoterapeutów na dzień 2021-08-31',
  11. (SELECT COUNT(*) FROM (SELECT sorga_ptchr_archive._d_Czlonkowie.id FROM sorga_ptchr_archive._d_Czlonkowie
  12. LEFT JOIN sorga_ptchr_data._d_Czlonkowie_BC ON sorga_ptchr_data._d_Czlonkowie_BC.masterId=sorga_ptchr_archive._d_Czlonkowie.id AND YEAR(`date`)='2021' AND rowType='charge' AND paymentDate <= '2021-08-31'
  13. WHERE `historyStartDate` <= '2021-08-31' AND (`historyEndDate` >= '2021-08-31' OR `historyEndDate` IS NULL) AND sorga_ptchr_data._d_Czlonkowie_BC.id IS NOT NULL
  14. GROUP BY id) AS x) AS 'Ilość członków z opłaconą składką za 2021',
  15.  
  16. #2020
  17. (SELECT COUNT(*) FROM (SELECT id FROM sorga_ptchr_archive._d_Czlonkowie WHERE                                   `historyStartDate` <= '2020-08-31' AND (`historyEndDate` >= '2020-08-31' OR `historyEndDate` IS NULL) GROUP BY id) AS x) AS 'Ilość członków na dzień 2020-08-31',
  18. (SELECT COUNT(*) FROM (SELECT id FROM sorga_ptchr_archive._d_Czlonkowie WHERE RIGHT(Imie, 1)='a' AND            `historyStartDate` <= '2020-08-31' AND (`historyEndDate` >= '2020-08-31' OR `historyEndDate` IS NULL) GROUP BY id) AS x) AS 'Ilość kobiet na dzień 2020-08-31',
  19. (SELECT COUNT(*) FROM (SELECT id FROM sorga_ptchr_archive._d_Czlonkowie WHERE RIGHT(Imie, 1)!='a' AND           `historyStartDate` <= '2020-08-31' AND (`historyEndDate` >= '2020-08-31' OR `historyEndDate` IS NULL) GROUP BY id) AS x) AS 'Ilość mężczyzn na dzień 2020-08-31',
  20. (SELECT COUNT(*) FROM (SELECT id FROM sorga_ptchr_archive._d_Czlonkowie WHERE Specjalizacja IS NOT NULL AND     `historyStartDate` <= '2020-08-31' AND (`historyEndDate` >= '2020-08-31' OR `historyEndDate` IS NULL) GROUP BY id) AS x) AS 'Ilość osób ze specjalizacją na dzień 2020-08-31',
  21. (SELECT COUNT(*) FROM (SELECT id FROM sorga_ptchr_archive._d_Czlonkowie WHERE Specjalizacja IS NULL AND         `historyStartDate` <= '2020-08-31' AND (`historyEndDate` >= '2020-08-31' OR `historyEndDate` IS NULL) GROUP BY id) AS x) AS 'Ilość osób bez specjalizacji na dzień 2020-08-31',
  22. (SELECT COUNT(*) FROM (SELECT id FROM sorga_ptchr_archive._d_Czlonkowie WHERE Zawod = 5 AND                     `historyStartDate` <= '2020-08-31' AND (`historyEndDate` >= '2020-08-31' OR `historyEndDate` IS NULL) GROUP BY id) AS x) AS 'Ilość lekarzy na dzień 2020-08-31',
  23. (SELECT COUNT(*) FROM (SELECT id FROM sorga_ptchr_archive._d_Czlonkowie WHERE Zawod = 8 AND                     `historyStartDate` <= '2020-08-31' AND (`historyEndDate` >= '2020-08-31' OR `historyEndDate` IS NULL) GROUP BY id) AS x) AS 'Ilość fizjoterapeutów na dzień 2020-08-31',
  24. (SELECT COUNT(*) FROM (SELECT sorga_ptchr_archive._d_Czlonkowie.id FROM sorga_ptchr_archive._d_Czlonkowie
  25. LEFT JOIN sorga_ptchr_data._d_Czlonkowie_BC ON sorga_ptchr_data._d_Czlonkowie_BC.masterId=sorga_ptchr_archive._d_Czlonkowie.id AND YEAR(`date`)='2020' AND rowType='charge' AND paymentDate <= '2020-08-31'
  26. WHERE `historyStartDate` <= '2020-08-31' AND (`historyEndDate` >= '2020-08-31' OR `historyEndDate` IS NULL) AND sorga_ptchr_data._d_Czlonkowie_BC.id IS NOT NULL
  27. GROUP BY id) AS x) AS 'Ilość członków z opłaconą składką za 2020',
  28.  
  29. #2019
  30. (SELECT COUNT(*) FROM (SELECT id FROM sorga_ptchr_archive._d_Czlonkowie WHERE                                   `historyStartDate` <= '2019-09-30' AND (`historyEndDate` >= '2019-09-30' OR `historyEndDate` IS NULL) GROUP BY id) AS x) AS 'Ilość członków na dzień 2019-09-30',
  31. (SELECT COUNT(*) FROM (SELECT id FROM sorga_ptchr_archive._d_Czlonkowie WHERE RIGHT(Imie, 1)='a' AND            `historyStartDate` <= '2019-09-30' AND (`historyEndDate` >= '2019-09-30' OR `historyEndDate` IS NULL) GROUP BY id) AS x) AS 'Ilość kobiet na dzień 2019-09-30',
  32. (SELECT COUNT(*) FROM (SELECT id FROM sorga_ptchr_archive._d_Czlonkowie WHERE RIGHT(Imie, 1)!='a' AND           `historyStartDate` <= '2019-09-30' AND (`historyEndDate` >= '2019-09-30' OR `historyEndDate` IS NULL) GROUP BY id) AS x) AS 'Ilość mężczyzn na dzień 2019-09-30',
  33. (SELECT COUNT(*) FROM (SELECT id FROM sorga_ptchr_archive._d_Czlonkowie WHERE Specjalizacja IS NOT NULL AND     `historyStartDate` <= '2019-09-30' AND (`historyEndDate` >= '2019-09-30' OR `historyEndDate` IS NULL) GROUP BY id) AS x) AS 'Ilość osób ze specjalizacją na dzień 2019-09-30',
  34. (SELECT COUNT(*) FROM (SELECT id FROM sorga_ptchr_archive._d_Czlonkowie WHERE Specjalizacja IS NULL AND         `historyStartDate` <= '2019-09-30' AND (`historyEndDate` >= '2019-09-30' OR `historyEndDate` IS NULL) GROUP BY id) AS x) AS 'Ilość osób bez specjalizacji na dzień 2019-09-30',
  35. (SELECT COUNT(*) FROM (SELECT id FROM sorga_ptchr_archive._d_Czlonkowie WHERE Zawod = 5 AND                     `historyStartDate` <= '2019-09-30' AND (`historyEndDate` >= '2019-09-30' OR `historyEndDate` IS NULL) GROUP BY id) AS x) AS 'Ilość lekarzy na dzień 2019-09-30',
  36. (SELECT COUNT(*) FROM (SELECT id FROM sorga_ptchr_archive._d_Czlonkowie WHERE Zawod = 8 AND                     `historyStartDate` <= '2019-09-30' AND (`historyEndDate` >= '2019-09-30' OR `historyEndDate` IS NULL) GROUP BY id) AS x) AS 'Ilość fizjoterapeutów na dzień 2019-09-30',
  37. (SELECT COUNT(*) FROM (SELECT sorga_ptchr_archive._d_Czlonkowie.id FROM sorga_ptchr_archive._d_Czlonkowie
  38. LEFT JOIN sorga_ptchr_data._d_Czlonkowie_BC ON sorga_ptchr_data._d_Czlonkowie_BC.masterId=sorga_ptchr_archive._d_Czlonkowie.id AND YEAR(`date`)='2019' AND rowType='charge' AND paymentDate <= '2019-09-30'
  39. WHERE `historyStartDate` <= '2019-09-30' AND (`historyEndDate` >= '2019-09-30' OR `historyEndDate` IS NULL) AND sorga_ptchr_data._d_Czlonkowie_BC.id IS NOT NULL
  40. GROUP BY id) AS x) AS 'Ilość członków z opłaconą składką za 2019'
  41.  
  42.  
  43.  
  44.  
  45.  
RAW Paste Data