>Hi All,
>
>I have a SQL problem I have no idea if I can solve it with one select (I can do with two, but this is not what i like to have)
>
>The problems comes from an import scenario.
>
>I have a table like
>
>c1 c2 c3 ...
>A a 1
>A b 2
>A b 3
>B c 4
>B d 4
>A b 3
>
>
>For a given c3 the combination of c1 and c2 should be the same. We can see that for c3=4 this is not true.
>
>How do I code a single SELECT SQL that returns just
>
>
>c1 c2 c3
>B c 4
>B d 4
>
>
>and
>
For this problem
select T.* from myTable T inner JOIN (select c1,c2,c3 from myTable group by c3,c1,c2) X on T.c3=X.c3 and (T.c1<>X.c1 or T.c2<>X.c2)
>
>c3
>4
>
>
>
Agnes,
To get c3 - 4
select c3 from (select c3, count(distinct(c1+c2)) as DistinctValues from myTable group by c3 having DistinctValues > 1) X
If it's not broken, fix it until it is.
My Blog