help me design this query

hotmalepiyush

Registered User.
Local time
Today, 04:46
Joined
Jun 3, 2008
Messages
60
Code:
[LEFT]SELECT June.Scrip, Avg(June.[Quantity Traded]) AS [AVG]
FROM June
WHERE (((June.[Trade Date])>Date()-14))
GROUP BY June.Scrip;[/LEFT]


the above query gives me average of Quantity traded for last 14 days...

now i want to see today's(or yesterday's) quantity traded as % of this average.. how should i go about it...

thanx
piyush
 
Something like this might work:

SELECT June.Scrip, Avg(June.[Quantity Traded]) AS [AVG],
[Quantity Traded on Day of Interest]/(Avg(June.[Quantity Traded])
FROM June

W
HERE (((June.[Trade Date])>Date()-14))
GROUP BY June.Scrip;

NOTE: You could also make the original query into a subquery, and then it would look something like

SELECT [Quantity Traded on Day of Interest]/[AVG] AS PctOfAvg FROM
(
SELECT June.Scrip, Avg(June.[Quantity Traded]) AS [AVG]
FROM June
W
HERE (((June.[Trade Date])>Date()-14))
GROUP BY June.Scrip
);

 
Last edited:

Users who are viewing this thread

Back
Top Bottom