fletchsod
Programmer
- Dec 16, 2002
- 181
I'm a bit surprised when I discover this recently... It wasn't made known to me for 8 years til now.
When you do this query...
Instead of 80 rows, I get the 1st 5 rows which works. When you do this average...
It average all 80 rows and I got $12,284 (PurchasePrice). But when I do this...
I still get $12,284 meaning it used all 80 rows instead of 5 rows.
Why is that? What's wrong with this sql-query?
Thanks...
When you do this query...
Code:
SELECT TOP 5 PurchasePrice from tblPurchase
WHERE Year = '2008'
AND Make = 'Ford'
AND Model = 'Mustang'
Instead of 80 rows, I get the 1st 5 rows which works. When you do this average...
Code:
SELECT AVG(PurchasePrice) from tblPurchase
WHERE Year = '2008'
AND Make = 'Ford'
AND Model = 'Mustang'
It average all 80 rows and I got $12,284 (PurchasePrice). But when I do this...
Code:
SELECT TOP 5 AVG(PurchasePrice) from tblPurchase
WHERE Year = '2008'
AND Make = 'Ford'
AND Model = 'Mustang'
I still get $12,284 meaning it used all 80 rows instead of 5 rows.
Why is that? What's wrong with this sql-query?
Thanks...