Guest User

Untitled

a guest
Jul 18th, 2018
94
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.64 KB | None | 0 0
  1. /*View the number of service requests of each complaint_type in each category*/
  2. SELECT category, compaint_type, count(*) FROM `nodal-component-204421.311_complaints.complaints`
  3. GROUP BY 1, 2
  4. ORDER BY 1, 3 DESC
  5.  
  6. /*Update Example - Single change*/
  7. UPDATE `nodal-component-204421.311_complaints.complaints`
  8. SET category = 'Advocate'
  9. WHERE LOWER(complaint_type) LIKE '%advocate%'
  10.  
  11. /*Update Example - Multiple changes*/
  12. UPDATE `nodal-component-204421.311_complaints.complaints`
  13. SET category = CASE
  14. WHEN LOWER(complaint_type) LIKE '%advocate%' THEN 'Advocate'
  15. WHEN LOWER(complaint_type) LIKE '%vending%' THEN 'Vending'
  16. ELSE category
  17. END
  18. WHERE category = 'Other'
Add Comment
Please, Sign In to add comment