 |
BorlandTalk.com Borland discussion newsgroups
|
| View previous topic :: View next topic |
| Author |
Message |
MarkR Guest
|
Posted: Thu Feb 05, 2004 12:37 am Post subject: Paradox TQuery - select and sum.... |
|
|
Hi guys,
I have a paradox table which I use a select statement using union on to
select two rows per table row.
example statment.
select leftcode as mycode, descript as fits, qtyinstock as stock, qtyonorder
as onorder from mytable union select rightcode as mycode, descript as fits,
qtyinstock2 as stock, qtyonorder2 as onorder from mytable
Now, I really want to return the total on order so i thought if I put
SUM(qtyinstock + qtyonorder) as STOCKAVAIL then this would be great. Alas I
get a message along the lines of you must use GROUP BY when mixing field
types.
So, how can I use GROUP BY in a statement which looks at one table twice for
each entry?
cheers
|
|
| Back to top |
|
 |
MarkR Guest
|
Posted: Thu Feb 05, 2004 12:49 am Post subject: Re: Paradox TQuery - select and sum.... |
|
|
Please ignore my post. I solved it.
select leftcode as mycode, descript as fits, sum(qtyinstock+ qtyonorder) as
totstock from mytable GROUP BY leftcode union
select leftcode as mycode, descript as fits, sum(qtyinstock2+ qtyonorder2)
as totstock from mytable GROUP BY rightcode
"MarkR" <markcr (AT) wapthespamntlworld (DOT) com> wrote
| Quote: | Hi guys,
I have a paradox table which I use a select statement using union on to
select two rows per table row.
example statment.
select leftcode as mycode, descript as fits, qtyinstock as stock,
qtyonorder
as onorder from mytable union select rightcode as mycode, descript as
fits,
qtyinstock2 as stock, qtyonorder2 as onorder from mytable
Now, I really want to return the total on order so i thought if I put
SUM(qtyinstock + qtyonorder) as STOCKAVAIL then this would be great. Alas
I
get a message along the lines of you must use GROUP BY when mixing field
types.
So, how can I use GROUP BY in a statement which looks at one table twice
for
each entry?
cheers
|
|
|
| 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
|
|