Help

Please help me with a sql query. I have a view with couple of joined tables which displays the results as
Name, Top,  Bottom and some other fields. The results looks like
AA  0      100
AA  100    175
AA   150   200
Now i need only one record for the above results as AA  0  200. Min of Top and Max of Bottom for each name.

Thanks
krisyashAsked:
Who is Participating?
 
Guy Hengel [angelIII / a3]Connect With a Mentor Billing EngineerCommented:
in short:
select Name, min(top), max(Bottom)from yroutable group by Name

Open in new window

0
 
Éric MoreauSenior .Net ConsultantCommented:
if angelIII solution doesn't work, try:
select distinct name
, (select min(YourFieldName) from YourTable where Name = A.Name)
, (select max(YourOtherFieldName) from YourTable where Name = A.Name)
from YourTable AS A
0
 
krisyashAuthor Commented:
Thank You all..I think its working.
0
 
Éric MoreauSenior .Net ConsultantCommented:
You need to accept one of the comment to close the question
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.