sagelib

Update Stat Cats - HRVHS Patrons (Grad Year/Class)

Oct 6th, 2016
42
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. --Match Grad Year to Class--
  2.  
  3. -- Only works when they have an entry in the Grad Year Stat Cat, have to create it otherwise --
  4.  
  5. -- 43 = Class
  6. -- 69 = Grad Year
  7. -- 214 = Hood River High School
  8.                
  9. BEGIN;
  10.  
  11. -- Seniors --
  12.            
  13.             UPDATE actor.stat_cat_entry_usr_map SET stat_cat_entry='Senior'
  14.                 WHERE stat_cat=43 and target_usr IN
  15.                 (
  16.             SELECT target_usr
  17.                 FROM actor.stat_cat_entry_usr_map
  18.                     WHERE stat_cat=69 AND stat_cat_entry ='2017'
  19.                     AND target_usr IN
  20.                         (SELECT id FROM actor.usr WHERE home_ou=214 AND deleted =false)
  21.                 )
  22.             ;
  23.            
  24. -- Juniors --
  25.            
  26.             UPDATE actor.stat_cat_entry_usr_map SET stat_cat_entry='Junior'
  27.                 WHERE stat_cat=43 and target_usr IN
  28.                 (
  29.             SELECT target_usr
  30.                 FROM actor.stat_cat_entry_usr_map
  31.                     WHERE stat_cat=69 AND stat_cat_entry ='2018'
  32.                     AND target_usr IN
  33.                         (SELECT id FROM actor.usr WHERE home_ou=214 AND deleted =false)
  34.                 )
  35.             ;
  36.            
  37. -- Sophomores --
  38.            
  39.             UPDATE actor.stat_cat_entry_usr_map SET stat_cat_entry='Sophomore'
  40.                 WHERE stat_cat=43 and target_usr IN
  41.                 (
  42.             SELECT target_usr
  43.                 FROM actor.stat_cat_entry_usr_map
  44.                     WHERE stat_cat=69 AND stat_cat_entry ='2019'
  45.                     AND target_usr IN
  46.                         (SELECT id FROM actor.usr WHERE home_ou=214 AND deleted =false)
  47.                 )
  48.             ;
  49.            
  50. -- Freshman --
  51.            
  52.             UPDATE actor.stat_cat_entry_usr_map SET stat_cat_entry='Freshman'
  53.                 WHERE stat_cat=43 and target_usr IN
  54.                 (
  55.             SELECT target_usr
  56.                 FROM actor.stat_cat_entry_usr_map
  57.                     WHERE stat_cat=69 AND stat_cat_entry ='2020'
  58.                     AND target_usr IN
  59.                         (SELECT id FROM actor.usr WHERE home_ou=214 AND deleted =false)
  60.                 )
  61.             ;
  62.            
  63. COMMIT;
Add Comment
Please, Sign In to add comment