R
Rick Campbell
The hair is going, in large clumps!!!!!
Using a median module from Kevin Kline's book. The module has the same
syntax as dAvg. It works on the table as a whole and it works on date
subsets. But, it is not working when I add another subset. I'm doing
something wrong and I can't figure it out.
Here's the working sql:
SELECT DISTINCTROW Sales.Style, (Format$(Sales.SoldDate,'yyyy')) AS
SaleDate, Format$(Avg(Sales.SoldPrice),'$#,###') AS Average,
Format$(CDbl(acbDMedian("SoldPrice","Sales","Format$(SoldDate,'yyyy') = '" &
Format$(Sales.SoldDate,'yyyy') & "' And Style = '" & Sales.Style &
"'")),'$#,###') AS Median, Format$(Count(*),'#,###') AS Sales,
Format$(Avg(Sales.DaysOnMarket),'#,###') AS DOM,
Format$([Average]/[ListPrice],'##.#%') AS [SP/LP], Avg(Sales.ListPrice) AS
ListPrice
FROM Sales
GROUP BY Sales.Style, Format$(Sales.SoldDate,'yyyy'), Year(Sales.SoldDate)-1
ORDER BY Sales.Style, Year(Sales.SoldDate)-1;
The following sql produces a median of $3,061 for each city:
SELECT DISTINCTROW Sales.Style, Sales.CityUp AS [City],
(Format$(Sales.SoldDate,'yyyy')) AS [Year],
Format$(Avg(Sales.SoldPrice),'$#,###') AS Average,
Format$(CDbl(acbDMedian("SoldPrice","Sales","Format$(SoldDate,'yyyy') = '" &
Format$(Sales.SoldDate,'yyyy') & "' And City = '" & Sales.CityUp & "' And
[Style] = '" & Sales.Style & "'")),'$#,###') AS Median, Count(*) AS Sales,
Avg(Sales.DaysOnMarket) AS DOM, [Average]/[ListPrice] AS [SP/LP],
Avg(Sales.ListPrice) AS ListPrice
FROM Sales
GROUP BY Sales.Style, Sales.CityUp, Format$(Sales.SoldDate,'yyyy'),
Year(Sales.SoldDate)-1
ORDER BY Sales.Style, Sales.CityUp, Year(Sales.SoldDate)-1;
If anyone can tell me what I'm doing wrong, I'll love ya, man!!!!
TIA
Rick
Using a median module from Kevin Kline's book. The module has the same
syntax as dAvg. It works on the table as a whole and it works on date
subsets. But, it is not working when I add another subset. I'm doing
something wrong and I can't figure it out.
Here's the working sql:
SELECT DISTINCTROW Sales.Style, (Format$(Sales.SoldDate,'yyyy')) AS
SaleDate, Format$(Avg(Sales.SoldPrice),'$#,###') AS Average,
Format$(CDbl(acbDMedian("SoldPrice","Sales","Format$(SoldDate,'yyyy') = '" &
Format$(Sales.SoldDate,'yyyy') & "' And Style = '" & Sales.Style &
"'")),'$#,###') AS Median, Format$(Count(*),'#,###') AS Sales,
Format$(Avg(Sales.DaysOnMarket),'#,###') AS DOM,
Format$([Average]/[ListPrice],'##.#%') AS [SP/LP], Avg(Sales.ListPrice) AS
ListPrice
FROM Sales
GROUP BY Sales.Style, Format$(Sales.SoldDate,'yyyy'), Year(Sales.SoldDate)-1
ORDER BY Sales.Style, Year(Sales.SoldDate)-1;
The following sql produces a median of $3,061 for each city:
SELECT DISTINCTROW Sales.Style, Sales.CityUp AS [City],
(Format$(Sales.SoldDate,'yyyy')) AS [Year],
Format$(Avg(Sales.SoldPrice),'$#,###') AS Average,
Format$(CDbl(acbDMedian("SoldPrice","Sales","Format$(SoldDate,'yyyy') = '" &
Format$(Sales.SoldDate,'yyyy') & "' And City = '" & Sales.CityUp & "' And
[Style] = '" & Sales.Style & "'")),'$#,###') AS Median, Count(*) AS Sales,
Avg(Sales.DaysOnMarket) AS DOM, [Average]/[ListPrice] AS [SP/LP],
Avg(Sales.ListPrice) AS ListPrice
FROM Sales
GROUP BY Sales.Style, Sales.CityUp, Format$(Sales.SoldDate,'yyyy'),
Year(Sales.SoldDate)-1
ORDER BY Sales.Style, Sales.CityUp, Year(Sales.SoldDate)-1;
If anyone can tell me what I'm doing wrong, I'll love ya, man!!!!
TIA
Rick