sonerkoksal
Programmer
let's just think a table has two columns named as A and B. i want to group records with A and filter if B is equal to some value. (i've already tried 'higher than' 'lower than' and etc.) I'm just using this code.
SELECT * FROM table GROUP BY A HAVING (B = 1 OR B = 2);
the table is:
- A - B
1. 1 - 1
2. 1 - 0
3. 2 - 2
4. 2 - 3
sql code that i've given works fine with this table and returns A = 1 and A = 2. but when i change order of the records like this
- A - B
1. 1 - 0
2. 1 - 1
3. 2 - 3
4. 2 - 2
and use the same code, it returns nothing. when we group A with '1' value, code does not look the second record. it looks A's first record and checks '0' value. not looking the second value with '1' value.
what is my wrong here and if there's another way to solve this i'd like to see. Thanks.
SELECT * FROM table GROUP BY A HAVING (B = 1 OR B = 2);
the table is:
- A - B
1. 1 - 1
2. 1 - 0
3. 2 - 2
4. 2 - 3
sql code that i've given works fine with this table and returns A = 1 and A = 2. but when i change order of the records like this
- A - B
1. 1 - 0
2. 1 - 1
3. 2 - 3
4. 2 - 2
and use the same code, it returns nothing. when we group A with '1' value, code does not look the second record. it looks A's first record and checks '0' value. not looking the second value with '1' value.
what is my wrong here and if there's another way to solve this i'd like to see. Thanks.