Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
| Author |
Topic |
|
srinathdhanaraj
Starting Member
2 Posts |
Posted - 2012-02-16 : 02:12:15
|
| Hi All, I have a table with the following values,i need the query for the following requirement. Input table: Field 1 Field 2 Field 3 Field 3 10000 AAAA A1 AA 10000 AAAA A2 BB 10000 AAAA A3 CC 10000 AAAA A4 DD 10000 AAAA 20000 AAAA A1 AA 20000 AAAA A2 BB 20000 AAAA A3 CC 20000 AAAA A4 DD 20000 AAAA 30000 AAAA 40000 AAAA 50000 AAAA 60000 AAAA 70000 AAAA i want a query which will give the following result Field 1 Field 2 Field 3 Field 3 10000 AAAA A1 AA 10000 AAAA A2 BB 10000 AAAA A3 CC 10000 AAAA A4 DD 20000 AAAA A1 AA 20000 AAAA A2 BB 20000 AAAA A3 CC 20000 AAAA A4 DD 30000 AAAA 40000 AAAA 50000 AAAA 60000 AAAA 70000 AAAA that is the the rows which are underlined (highlighted in red)in the input table needs to be eliminated. condition is that if there is a value in field 3 for the field 1 then the rows with null value in field 3 should not be there in the output. if there is only one record for a key with null value then it should be included in the output. Thanks in Advance!!!Srinath D |
|
|
kcanakli
Starting Member
8 Posts |
Posted - 2012-02-16 : 02:16:29
|
| Maybe,Select f1,f2,f3,xf2,xf3from (Select f1, f2, f3, xf2 = length(f2), xf3 = length(f3) from table group by f1,f2,f3) xxorder by xf3 desc, xf2 desc |
 |
|
|
srinathdhanaraj
Starting Member
2 Posts |
Posted - 2012-02-16 : 02:17:45
|
| Sorry the input table values are not getting highlighted, the row no 5 and row no 10 in the input table needs to be eliminated through the query.Thanks Srinath D |
 |
|
|
|
|
|
|
|