Loading...

sqlite-users@sqlite.org

[Prev] Thread [Next]  |  [Prev] Date [Next]

Re: [sqlite] count distinct group by Igor Tandetnik Wed Jul 28 16:02:06 2010

Peng Yu <[EMAIL PROTECTED]> wrote:
> Suppose that I have a table of 4 columns.
> 
> S      R1           R2       T
> --------------------------------
> s1    r1             r2         t1
> s1    r1             r2         t2
> s2    r3             r4         t5
> s2    r5             r4         t6
> s3    r6             r7         t7
> s3    r6             r8         t9
> s4    r9             r10       t10
> 
> I want to select only the rows where if S column are the same, R1
> column is the same and R2 column is the same.

select * from mytable where s in
(select s from mytable
 group by s
 having min(r1)=max(r1) and min(r2)=max(r2)
);

-- 
Igor Tandetnik


_______________________________________________
sqlite-users mailing list
[EMAIL PROTECTED]
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users