?
Solved

Help

Posted on 2008-06-10
4
Medium Priority
?
173 Views
Last Modified: 2010-03-20
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
0
Comment
Question by:krisyash
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
4 Comments
 
LVL 143

Accepted Solution

by:
Guy Hengel [angelIII / a3] earned 2000 total points
ID: 21756784
in short:
select Name, min(top), max(Bottom)from yroutable group by Name

Open in new window

0
 
LVL 70

Expert Comment

by:Éric Moreau
ID: 21758198
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
 

Author Comment

by:krisyash
ID: 21761000
Thank You all..I think its working.
0
 
LVL 70

Expert Comment

by:Éric Moreau
ID: 21762957
You need to accept one of the comment to close the question
0

Featured Post

Survive A High-Traffic Event with Percona

Your application or website rely on your database to deliver information about products and services to your customers. You can’t afford to have your database lose performance, lose availability or become unresponsive – even for just a few minutes.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Ever needed a SQL 2008 Database replicated/mirrored/log shipped on another server but you can't take the downtime inflicted by initial snapshot or disconnect while T-logs are restored or mirror applied? You can use SQL Server Initialize from Backup…
In the first part of this tutorial we will cover the prerequisites for installing SQL Server vNext on Linux.
Familiarize people with the process of retrieving data from SQL Server using an Access pass-thru query. Microsoft Access is a very powerful client/server development tool. One of the ways that you can retrieve data from a SQL Server is by using a pa…
Via a live example, show how to set up a backup for SQL Server using a Maintenance Plan and how to schedule the job into SQL Server Agent.

719 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question