C:\Users\pengsir>sqlite3 e:\\test.db
sqlite> create table test (f1 TEXT,f2 TEXT, f3 TEXT);
sqlite> insert into test values("x1","y1","w1");
sqlite> insert into test values("x1","y1","w2");
sqlite> insert into test values("x1","y3","w2");
sqlite> insert into test values("x2","y3","w2");
sqlite> insert into test values("x3","y4","w4");
sqlite> insert into test values("x2","y3","w4");
sqlite> insert into test values("x1","y3","w2");
select f1,f2 from test where count(f2)>1 group by f1,f2;
I get the error message:Error: misuse of aggregate:,i want to get the f1 and f2 combination which the value of f1 is the same ,two or more same value of f2 to be selected,that is to say ,i want to select
x1|y1
x1|y3
x2|y3
I can do that by two sqlite commands:
sqlite> create table tmp1 as
...> select f1,f2,count(f2) as v from test group by f1,f2;
sqlite> select f1,f2 from tmp1 where v>1 ;
How to simplify my sqlite commands?
select f1, f2, count(f2) cf2 from test where cf2 > 1 group by f1, f2?