sql - problem with select -
I have a table with two column rows
A1A2B1 B3C1C2C3 And I want to get it only from this ID (A, B or C) which contains only 2 rows with value 2, from this table I should have got, the row with 2 does not have a sequence of beakus, and there are rows with 1 and b in C, but it also has row with C. ..
What is the simplest way?
Calling your table by calling col1 call 1 (separate call 2) = 2 and the minimum (call2) = 1 and maximum (col2) = 2 or another extension for more than 2 numbers
SELECT Col1 HAVING MIN (case when COL2 IN (1, 2) then 1 ELSE 0 END) = 1 and COUNT (DISTINCT col2) = 2 from yourtable group to col1
Comments
Post a Comment