Sql……select | SQL Server Performance Forums

SQL Server Performance Forum – Threads Archive

Sql……select

This is my table
Co Name Count
522 Ja 4
522 Ho 4
528 Ri 5
123 Jame 1
123 Timmy 1
678 Nu 7 The result that I am trying to do is 522 Ja 4
528 Ri 5
123 Jame 1
678 Nu 7 In other word, I want the value that is duplicated in field Count return just only one…… !! Any comment !!
Try this Select Co,Name,Count from yourTable T
where Name=(Select top 1 Name from yourTable where Co=T.Co and Count=T.count) Madhivanan Failing to plan is Planning to fail
hey! is that possible ?
i think it’s not but u can display this
522 4
528 5
123 1
678 5 by running this command select co,count from table
group by co,count
krishna chaitanya sanka
project engineer-SQLDBA ‘TO IMPROVE IS TO CHANGE….TO BE PERFECT IS TO CHANGE OFTEN!!!!

chaitu1385, mine is what the questioner needed [<img src=’/community/emoticons/emotion-1.gif’ alt=’:)‘ />]<br /><br />Madhivanan<br /><br />Failing to plan is Planning to fail
select co,max(name),cnt
from t1
group by co,cnt
hey sorry for my reply what madhavan said is really working thanx madhavan……i didn’t try what u said before my first reply krishna chaitanya sanka
project engineer-SQLDBA ‘TO IMPROVE IS TO CHANGE….TO BE PERFECT IS TO CHANGE OFTEN!!!!

quote:Originally posted by ranjitjain select co,max(name),cnt
from t1
group by co,cnt

Instead of 123 Jame 1 your query will return 123 Timmy 1
Madhivanan Failing to plan is Planning to fail
&gt;&gt;thanx madhavan……i didn’t try what u said before my first reply<br /><br />No Problem [<img src=’/community/emoticons/emotion-1.gif’ alt=’:)‘ />]<br /><br />Madhivanan<br /><br />Failing to plan is Planning to fail
Madhivanan,
Read posters questions again……
>>>>>>>In other word, I want the value that is duplicated in field Count return just only one…… !! Any comment !! He wants only one record irrespective of name from this line it suggests.
But his desired result is just an example i guess…………. Anyways i’m providing the above query according to the line>>>>>>>>>>>>>I want the value that is duplicated in field Count return just only one
Well. In that case you are right [<img src=’/community/emoticons/emotion-1.gif’ alt=’:)‘ />]<br /><br />Madhivanan<br /><br />Failing to plan is Planning to fail
Finally you got convinced[<img src=’/community/emoticons/emotion-5.gif’ alt=’;)‘ />]<br /><blockquote id="quote"><font size="1" face="Verdana, Arial, Helvetica" id="quote">quote:<hr height="1" noshade id="quote"><i>Originally posted by Madhivanan</i><br /><br />Well. In that case you are right [<img src=’/community/emoticons/emotion-1.gif’ alt=’:)‘ />]<br />Madhivanan<br />Failing to plan is Planning to fail<br /><hr height="1" noshade id="quote"></font id="quote"></blockquote id="quote"><br />Well lets wait for question poster to reply.[}<img src=’/community/emoticons/emotion-1.gif’ alt=’:)‘ />]
&gt;&gt;Finally you got convinced<br /><br />Yes. No Problem [<img src=’/community/emoticons/emotion-1.gif’ alt=’:)‘ />]<br />I posted query only based on expected result [<img src=’/community/emoticons/emotion-1.gif’ alt=’:)‘ />]<br /><br />Madhivanan<br /><br />Failing to plan is Planning to fail
]]>