Guest User

Untitled

a guest
Jan 12th, 2018
336
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.15 KB | None | 0 0
  1. # Purpose: Find any phenomena+significance combinations which occur more than once in wwa_classification_scheme_id=1 (email alerts)
  2. SELECT
  3. watm.wwa_phenomena_lut_code,
  4. watm.wwa_significance_lut_code,
  5. count(watm.id)
  6. FROM wwa_alert_type_members watm
  7. INNER JOIN wwa_alert_types wat ON watm.wwa_alert_type_id = wat.id
  8. WHERE
  9. wat.wwa_classification_scheme_id = 1
  10. GROUP BY
  11. watm.wwa_phenomena_lut_code, watm.wwa_significance_lut_code
  12. HAVING
  13. count(watm.id) > 1;
  14.  
  15. wwa_phenomena_lut_code | wwa_significance_lut_code | count
  16. ------------------------+---------------------------+-------
  17. MF | Y | 2
  18. MS | Y | 2
  19. FA | Y | 2
  20. (3 rows)
  21.  
  22. # Purpose: Provide more details on when/how these codes are repeated.
  23. SELECT
  24. watm.wwa_phenomena_lut_code,
  25. watm.wwa_significance_lut_code,
  26. wat.description,
  27. wat.wwa_classification_scheme_id
  28. FROM wwa_alert_type_members watm
  29. INNER JOIN wwa_alert_types wat ON watm.wwa_alert_type_id = wat.id
  30. WHERE
  31. (watm.wwa_phenomena_lut_code || watm.wwa_significance_lut_code) IN ('MFY','MSY','FAY')
  32. ORDER BY
  33. watm.wwa_phenomena_lut_code, watm.wwa_significance_lut_code;
  34.  
  35. wwa_phenomena_lut_code | wwa_significance_lut_code | description | wwa_classification_scheme_id
  36. ------------------------+---------------------------+----------------+------------------------------
  37. FA | Y | Flood Warnings | 1
  38. FA | Y | Flood Warnings | 1
  39. FA | Y | Flood | 2
  40. MF | Y | Fog Advisories | 1
  41. MF | Y | Marine Weather | 1
  42. MS | Y | Fog Advisories | 1
  43. MS | Y | Marine Weather | 1
  44. (7 rows)
Add Comment
Please, Sign In to add comment