sql - sqlite count of distinct occurences -
What is the best way to write an SQLLay query that will calculate the incidence of colc after selecting different cola? Select
Cola, colB, colC from MyTable where in Cola ('121', '122', '123', '124', '125', '126', '127 ',' 128 ',' 129 ');
Information Cola should be different.
However close, these results are wrong.
should return it:
123 a cat 1
124b dog 1
125 e serpent 2
126f fish 1
127g snake 2
(select cola, min (colB) colB, max (colC) from MyTable as colC where in cola ('121' , '122', '123 *,' 124 ',' 125 ',' 126 ',' 127 ',' 128 ', '129') Group by Cola Switch to TV. *, Coupled with c.colC_count (select, count (*) clc = tcol
explanation:
first subkey (inside with
) gets the desired result but calculates the value recurrence of each colc
in the desired result without counting the column and this count is returned to the end result.
There is very useful with the result of the first subquery
is used in two places. Information:
Before version 3.8.3 for SQLite, query:
SELECT t. *, C.colC_count FROM (select colA, min (colB) AS colB, colC from MyTable where cola ('121', '122', '123', '124', '125', '126', '127', '128', '129') Cola group of cola) (select colC, * count) as colC_count (selection max (colC) from MyTable to colC where in cola ('121', '122', '123', '124', '125 '126', '127', '128', '129 ') Cola by group) COC by C group) COCCOLC = TCLC
Comments
Post a Comment