count - Sqlite and counting the frequency of multiple fields -


i have table named "number" 4 columns (id, n1,n2,n3) this:

id = 1,2 3, 4   n1 = 22 , 14 , 13 , 15  n2 = 13 , 11 , 80 , 11  n3 = 11 , 22 , 47 , 23 

can count total frequency of individual numbers in table? (11 = 3) ** (22=2) etc..

for 1 column query is:

"select n1, count(*) frequency number group n1 order count(*) desc" 

thanks possible help

try this:

select t.num, count(t.num) (select n1 num number       union       select n2 num number       union       select n3 num number) t group t.num order count(t.num) desc; 

fiddle demo

union operator


Comments

Popular posts from this blog

assembly - 8086 TASM: Illegal Indexing Mode -

Java, LWJGL, OpenGL 1.1, decoding BufferedImage to Bytebuffer and binding to OpenGL across classes -

javascript - addthis share facebook and google+ url -