Wednesday, July 27, 2016

CASE n RANK Function in T-SQL

CASE n RANK Function in T-SQL


--CASE
SELECT
     SUM(CASE WHEN Rate>0 AND Rate<10 THEN 1 ELSE NULL END) sal1,
SUM(CASE WHEN Rate>10 AND Rate<20 THEN 1 ELSE NULL END) sal2,
SUM(CASE WHEN Rate>20 AND Rate<100 THEN 1 ELSE NULL END) sal3,      
SUM(CASE WHEN Rate>100 AND Rate<10000 THEN 1 ELSE NULL END) sal4 
  FROM HumanResources.EmployeePayHistory


--RANK
SELECT  Rate,   
       RANK() OVER (ORDER BY Rate DESC) AS RankBySalary  
FROM HumanResources.EmployeePayHistory AS cmp ; 

11 comments:

  1. That's a Great Article and more useful for anyone.Thanks for sharing...
    oracle course in chennai

    ReplyDelete
  2. Great post I would like to thank you for the efforts you have made in writing this interesting and knowledgeable article. adult sex

    ReplyDelete
  3. This implies you don't need to invest as much energy and cash either preparing existing staff, or employing engineers. Change Site URL Using MySQL

    ReplyDelete
  4. I haven’t any word to appreciate this post.....Really i am impressed from this post....the person who create this post it was a great human..thanks for shared this with us. 事件・事故まとめ

    ReplyDelete
  5. I was surfing net and fortunately came across this site and found very interesting stuff here. Its really fun to read. I enjoyed a lot. Thanks for sharing this wonderful information. 裁判判例と未解決事件データベース

    ReplyDelete
  6. Pretty nice post. I just stumbled upon your weblog and wanted to say that I have really enjoyed browsing your blog posts. After all I’ll be subscribing to your feed and I hope you write again soon! dotcom secrets

    ReplyDelete
  7. If you are looking for more information about flat rate locksmith Las Vegas check that right away. Samsung S21 Ultra case with S pen holder

    ReplyDelete
  8. Positive site, where did u come up with the information on this posting?I have read a few of the articles on your website now, and I really like your style. Thanks a million and please keep up the effective work. Nokia 8.3 case

    ReplyDelete
  9. I’m impressed, I must say. Actually rarely must i encounter a weblog that’s both educative and entertaining, and let me tell you, you may have hit the nail for the head. Your notion is outstanding; the pain is something that not enough individuals are speaking intelligently about. My business is happy we found this at my seek out something regarding this. best SQL courses

    ReplyDelete
  10. The giving of these authentications were genuinely uncommon on the grounds that it could require various long stretches of difficult work to acquire one, similar to now individuals moved around so they once in a while needed to gain from various educators, and a few teachers simply didn't give them out. local citation building

    ReplyDelete