Created
          September 27, 2018 21:17 
        
      - 
      
- 
        Save smalik/b8a9b26a3e4b9dfdd4c3a1b5a51c565a to your computer and use it in GitHub Desktop. 
    SQL Code for mean absolute deviation
  
        
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | SELECT id, MEDIAN(ABS(value - med)) | |
| FROM ( | |
| SELECT id, value, MEDIAN(value) OVER(PARTITION BY id) AS med | |
| FROM mytable | |
| ) | |
| GROUP BY | |
| id | 
  
    Sign up for free
    to join this conversation on GitHub.
    Already have an account?
    Sign in to comment