BorlandTalk.com Forum Index BorlandTalk.com
Borland discussion newsgroups
 
Archives   FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

SQL Query Question

 
Post new topic   Reply to topic    BorlandTalk.com Forum Index -> Delphi Databases (Desktop)
View previous topic :: View next topic  
Author Message
Lee Cook
Guest





PostPosted: Tue Aug 15, 2006 8:25 pm    Post subject: SQL Query Question Reply with quote



Hi again,

Is this possible?

I create a query on some tables which might say return 6 records like so

MAN TFS £100
MAN TFS £110
MAN TFS £120
LGW TFS £130
LGW TFS £140
LGW TFS £150

What I would like to do is in the query is only display the cheapest for
each route so it would actually return

MAN TFS £100
LGW TFS £130

Is this possible?

Thanks

Lee
Back to top
Wayne Niddery [TeamB]
Guest





PostPosted: Tue Aug 15, 2006 11:06 pm    Post subject: Re: SQL Query Question Reply with quote



Lee Cook wrote:
Quote:
I create a query on some tables which might say return 6 records like
so
MAN TFS £100
MAN TFS £110
MAN TFS £120
LGW TFS £130
LGW TFS £140
LGW TFS £150

What I would like to do is in the query is only display the cheapest
for each route so it would actually return

MAN TFS £100
LGW TFS £130

Is this possible?

select fld1, fld2, MIN(fld3)
from table
group by fld1, fld2

--
Wayne Niddery - Winwright, Inc (www.winwright.ca)
"In a tornado, even turkeys can fly." - unknown
Back to top
Lee Cook
Guest





PostPosted: Wed Aug 16, 2006 1:49 pm    Post subject: Re: SQL Query Question Reply with quote



Wayne,

Thanks for this, Can i use order by aswell as i need the results in Fld3
order?

Lee


"Wayne Niddery [TeamB]" <wniddery (AT) chaffaci (DOT) on.ca> wrote in message
news:44e20d19 (AT) newsgroups (DOT) borland.com...
Quote:
Lee Cook wrote:
I create a query on some tables which might say return 6 records like
so
MAN TFS £100
MAN TFS £110
MAN TFS £120
LGW TFS £130
LGW TFS £140
LGW TFS £150

What I would like to do is in the query is only display the cheapest
for each route so it would actually return

MAN TFS £100
LGW TFS £130

Is this possible?

select fld1, fld2, MIN(fld3)
from table
group by fld1, fld2

--
Wayne Niddery - Winwright, Inc (www.winwright.ca)
"In a tornado, even turkeys can fly." - unknown
Back to top
Wayne Niddery [TeamB]
Guest





PostPosted: Wed Aug 16, 2006 9:09 pm    Post subject: Re: SQL Query Question Reply with quote

Lee Cook wrote:
Quote:

Thanks for this, Can i use order by aswell as i need the results in
Fld3 order?

Should be able to, try

order by 3


--
Wayne Niddery - Winwright, Inc (www.winwright.ca)
"Reality is that which, when you stop believing in it, doesn't go
away." — Philip K. Dick
Back to top
Lee Cook
Guest





PostPosted: Thu Aug 17, 2006 2:28 pm    Post subject: Re: SQL Query Question Reply with quote

Wayne,

That didnt work but this does

select fld1, fld2, MIN(fld3)AS price
from table
group by fld1, fld2
order by price


Cheers

Lee


"Wayne Niddery [TeamB]" <wniddery (AT) chaffaci (DOT) on.ca> wrote in message
news:44e34335$2 (AT) newsgroups (DOT) borland.com...
Quote:
Lee Cook wrote:

Thanks for this, Can i use order by aswell as i need the results in
Fld3 order?

Should be able to, try

order by 3


--
Wayne Niddery - Winwright, Inc (www.winwright.ca)
"Reality is that which, when you stop believing in it, doesn't go
away." - Philip K. Dick
Back to top
Display posts from previous:   
Post new topic   Reply to topic    BorlandTalk.com Forum Index -> Delphi Databases (Desktop) All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2006 phpBB Group
SEO toolkit © 2004-2006 webmedic.