 |
BorlandTalk.com Borland discussion newsgroups
|
| View previous topic :: View next topic |
| Author |
Message |
Lee Cook Guest
|
Posted: Tue Aug 15, 2006 8:25 pm Post subject: SQL Query Question |
|
|
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
|
Posted: Tue Aug 15, 2006 11:06 pm Post subject: Re: SQL Query Question |
|
|
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
|
Posted: Wed Aug 16, 2006 1:49 pm Post subject: Re: SQL Query Question |
|
|
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
|
Posted: Wed Aug 16, 2006 9:09 pm Post subject: Re: SQL Query Question |
|
|
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
|
Posted: Thu Aug 17, 2006 2:28 pm Post subject: Re: SQL Query Question |
|
|
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 |
|
 |
|
|
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
|
|