Watch Pre-recorded Live Shows Here
Why Join
Become a member
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
C# Corner Home
Technologies
Monthly Leaders
ASK A QUESTION
Forum guidelines
Sai Reddy
1.9k
214
21.6k
Quartile Number for group
Sep 19 2020 10:27 AM
Hi, I am trying to get quartile target each member, can you please help me with the logic?
create table sc
(
Name varchar(30),
Score int
)
insert into sc values ('abc',100)
insert into sc values ('xyz',200)
insert into sc values ('xyz2',90)
insert into sc values ('abc2',80)
insert into sc values ('abc3',300)
insert into sc values ('ahz',50)
insert into sc values ('Sai',70)
insert into sc values ('Raj',0)
;with test as (
select Name,Score,row_number() over(order by score) rank from sc
)
select Name,Score,rank,
(
case when rank<=(select count(1)*.25 from test) then 1
when rank<=(select count(1)*.50 from test) then 2
when rank<=(select count(1)*.75 from test) then 3
else 4 end
) Quartile from test
Reply
Answers (
3
)
What must updated null flag updated or conflict flag updated?
Optimize sql query