Advertisement
DataCCIW

Grade Discrepancy

Jul 30th, 2019
384
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
T-SQL 0.83 KB | None | 0 0
  1. SELECT P.person_id
  2. , person_name = P.nick_name + ' ' + P.last_name
  3. , Member_Status = L.lookup_value
  4. , P.birth_date
  5. , Age = dbo.fn_Age(P.birth_date,getdate())
  6. , Grade_As_Entered = dbo.core_funct_grade_name(P.graduation_date,getdate(),1)
  7. , Grade_Based_On_DOB = dbo.core_funct_grade_name(DATEADD(YEAR,(CASE WHEN DATEPART(MONTH,P.birth_date) >= 9 THEN 19 ELSE 18 END),P.birth_date),getdate(),1)
  8. , Grad_Year_Entered = YEAR(P.graduation_date)
  9. , Grad_Year_Per_DOB = YEAR(P.birth_date) + (CASE WHEN DATEPART(MONTH,P.birth_date) >= 9 THEN 19 ELSE 18 END)
  10. , P.medical_information
  11. FROM core_person P
  12. JOIN core_lookup L on P.member_status = L.lookup_id
  13. WHERE P.birth_date <> '1/1/1900'
  14. AND P.graduation_date <> '1/1/1900'
  15. AND YEAR(P.birth_date) + 18 NOT BETWEEN YEAR(P.graduation_date) - 2 AND YEAR(P.graduation_date) + 1
  16. ORDER BY P.graduation_date
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement