sort items based on their appears count

Posted by ANIL MANE on Stack Overflow See other posts from Stack Overflow or by ANIL MANE
Published on 2010-04-23T06:00:52Z Indexed on 2010/04/23 6:03 UTC
Read the original article Hit count: 366

Filed under:
|
|

Hello Experts,

I have data like this

d b c

a d

c b

a b

c a

c a d

c

if you analyse, you will find the appearance of each element as follows

a: 4 b: 3 c: 5 d: 2

According to appearance my sorted elements would be c,a,b,d

and final output should be

c b d

a d

c b

a b

c a

c a d

c

Any clue, how we can achieve this using sql query ?

© Stack Overflow or respective owner

Related posts about sql

Related posts about tsql