Joining 2 Queries

C

carl

I have 2 queries:

Query1
SELECT (count(TradeVolume)/2) AS TotalVolume
FROM HILLTOP;

Query2
SELECT (sum(TradeVolume)/2) AS TotalVolume
FROM HILLTOP;

Trying to combine the 2 and get output like this:

Total_Volume:_Result of Query1
Total_Trades:_Result of Query2

Thank You in Advance.
 
L

Lord Kelvan

select query1.totalvolume as Total_Volume, query2.totalvolume as
total_trades
from query1,query2

note that query will only work if you have a single value in each
table but from the appears of the queries you do so there should be no
problem

hope this helps

Regards
Kelvan
 
J

Jeff Boyce

I'm confused...

From your description, you appear to be counting the number of records with
[TradeVolume] entries and dividing by two, calling it "Total Volume".

Then you are summing all the values contained in [TradeVolume] and dividing
by two, and calling THAT "Total Volume".

So, what is it, the count or the sum? (and why divide by 2?)

More info, please...

Regards

Jeff Boyce
Microsoft Office/Access MVP
 
M

MGFoster

carl said:
I have 2 queries:

Query1
SELECT (count(TradeVolume)/2) AS TotalVolume
FROM HILLTOP;

Query2
SELECT (sum(TradeVolume)/2) AS TotalVolume
FROM HILLTOP;

Trying to combine the 2 and get output like this:

Total_Volume:_Result of Query1
Total_Trades:_Result of Query2

Thank You in Advance.

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

You could use a UNION query:

SELECT TotalVolume As Total_Volume FROM Query1
UNION
SELECT TotalVolume As Total_Trades FROM Query2

--
MGFoster:::mgf00 <at> earthlink <decimal-point> net
Oakland, CA (USA)
** Respond only to this newsgroup. I DO NOT respond to emails **

-----BEGIN PGP SIGNATURE-----
Version: PGP for Personal Privacy 5.0
Charset: noconv

iQA/AwUBSL21vIechKqOuFEgEQLf+wCgvwaNfVTRflSo6blL4vUxSoeLUz8An0jt
Ps3fQFcG/30zzuW32JBb5In/
=/YaZ
-----END PGP SIGNATURE-----
 
K

KARL DEWEY

Why not do it this way ---
SELECT (count(TradeVolume)/2) AS Total_Volume, (sum(TradeVolume)/2) AS
Total_Trades
FROM HILLTOP;
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top