Advertisement
Guest User

ramkaka

a guest
Oct 14th, 2019
91
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.36 KB | None | 0 0
  1. SELECT
  2.  
  3. I.progres_countryoforiginidname,
  4.  
  5. I.progres_refugeestatusname,
  6.  
  7. Count(DISTINCT CASE
  8.  
  9. WHEN progres_age <= 4 THEN progres_individualid
  10.  
  11. ELSE NULL END) AS [ 1-5 ],
  12.  
  13. Count(DISTINCT CASE
  14.  
  15. WHEN progres_age BETWEEN 5 AND 11 THEN progres_individualid
  16.  
  17. ELSE NULL END) AS [ 5 - 10 ],
  18.  
  19. Count(DISTINCT CASE
  20.  
  21. WHEN progres_age BETWEEN 12 AND 17 THEN progres_individualid
  22.  
  23. ELSE NULL END) AS [ 10 - 17 ],
  24.  
  25.  
  26.  
  27. Count(distinct n.progres_individualname)
  28.  
  29. FROM
  30.  
  31. Filteredprogres_specificneed N Inner join Filteredprogres_individual I on N.progres_individualname = I.progres_indvidualid
  32.  
  33. WHERE
  34.  
  35. N.progres_spnsubcategory2name = 'Child at risk of not attending school'
  36.  
  37. and n.statuscodename = 'Active'
  38.  
  39. and n.progres_specificneedstatusname ='Valid'
  40.  
  41. and I.StatusCodeName in('Active','hold')
  42.  
  43. and (I.progres_refugeestatusname in('Asylum Seeker','Refugee') or I.progres_countryoforiginidname like '%syr%')
  44.  
  45.  
  46.  
  47. Group by I.progres_countryoforiginidname,I.progres_refugeestatusname
  48.  
  49. Order by I.progres_countryoforiginidname ,count(distinct n.progres_individualname) DESC
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement