hi,
I have a table, which contain 8 different columns. I need to figure out the values which are same across selected four columns with in a table. In the same query, i want to see the value in those two columns where values are different.
An example would be as follows,
Table Name: Table1
Columns in the table: A, B, C, D, E, F, G, H
Scenario1:
A = B = C = D and
E <> F
Scenario2:
A = B = C = D and
G <> H
Scenario3:
A = B = C = D and
E = F and
G<>H
Scenario4:
A = B = C = D and
E <> F and
G <> H
Scenario5:
A = B = C = D and
E <> F and
G = H
I was abale to figure out a query, which will bring 4 equall values. But it also brings two equal values. This is not i want. I am interested to see the rows, which has same value for all the four columns and ofcourse it should meet other additional criterias also.
Below is the query which i used,
PLEASE HELP ME WITH THIS.
Thanks,VIJSQL01
I have a table, which contain 8 different columns. I need to figure out the values which are same across selected four columns with in a table. In the same query, i want to see the value in those two columns where values are different.
An example would be as follows,
Table Name: Table1
Columns in the table: A, B, C, D, E, F, G, H
Scenario1:
A = B = C = D and
E <> F
Scenario2:
A = B = C = D and
G <> H
Scenario3:
A = B = C = D and
E = F and
G<>H
Scenario4:
A = B = C = D and
E <> F and
G <> H
Scenario5:
A = B = C = D and
E <> F and
G = H
I was abale to figure out a query, which will bring 4 equall values. But it also brings two equal values. This is not i want. I am interested to see the rows, which has same value for all the four columns and ofcourse it should meet other additional criterias also.
Below is the query which i used,
Code:
SELECT a.*
FROM RT_State_Master a
INNER JOIN
(
SELECT Rent_Max , Rent_Min, Rent_Mean, Rent_Median, COUNT(*) totalCount
FROM RT_State_Master
GROUP BY Rent_Max , Rent_Min, Rent_Mean, Rent_Median
HAVING COUNT(*) > 1
) b ON a.Rent_Max = b.Rent_Max AND
a.Rent_Min = b.Rent_Min AND
a.Rent_Mean = b.Rent_Mean AND
a.Rent_Median = b.Rent_Median
PLEASE HELP ME WITH THIS.
Thanks,VIJSQL01