Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
![]() |
![]() |
Home -> Community -> Usenet -> c.d.o.misc -> How would I do this with Oracle 7 SQL ?
I have two tables where in each case the first set of columns are the
primary
keys and the second sets are numbers.
Purchases
Year Week Location ProductGroup ProductDept Brand Sales Baskets Visits Year Week Location Visitors
With Microsoft Access I can write a query like this which will sum amounts
from the two
tables independently and then perform some calculations with them.
SELECT Pu.Year, Pu.Week, Sum(Pu.Sales) AS TotalSales, Sum(Pu.Baskets) AS
TotalBaskets,
(SELECT Sum(Visitors) from Visitors Vi
WHERE Pu.Year = Vi.Year
and Pu.Week = Vi.Week
GROUP BY Vi.Year, Vi.Week ) AS Visitors2,
Sum(Pu.Sales) / Visitors2 AS PerVisitor, 100 * Sum(Pu.Baskets) / Visitors2
AS Penetration
FROM Purchases AS Pu
GROUP BY Pu.Year, Pu.Week;
How would I do this with Oracle 7 SQL ?
Thanks
Adrian Hodson
Received on Thu Sep 10 1998 - 16:39:10 CDT
![]() |
![]() |