Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /* AVG */
- -- AVG(Rate) OVER (PARTITION BY group_Id) AS AvgRate
- -- 2 89,9090909090909
- -- 3 58,3333333333333
- /* NTILE */
- WITH truncatedSet AS (SELECT Rate, ntile(10) OVER(ORDER BY Rate) AS n FROM RateCalculatorLookups WHERE rate IS NOT NULL AND group_id = 3)
- SELECT * FROM truncatedSet
- -- 50 1 -- gets removed
- -- 50 2
- -- 50 3
- -- 50 4
- -- 50 5
- -- 100 6 -- should be removed
- SELECT avg(Rate) FROM truncatedSet WHERE n BETWEEN 2 AND 19
- -- 60
Advertisement
Add Comment
Please, Sign In to add comment