![]() |
I'd like to compute the average age of my users for statistical information.
Any ideas on how to write this query? |
The query:
Code:
SELECT YEAR(NOW())-AVG(YEAR(birthday)) AS avgage FROM user; Code:
SELECT [high]ROUND([/high]YEAR(NOW())-AVG(YEAR(birthday))[high],2)[/high] AS avgage FROM user; |
How can I eliminate the ones that didn't input a year?
|
wow sweet!
Where would I put this code and where would I recieve the results! |
[QUOTE]Originally posted by pgowder
How can I eliminate the ones that didn't input a year? |
Here is what I tried:
[QUOTE]SELECT YEAR(NOW())-AVG(YEAR(birthday)) AS avgage WHERE birthday != 0000-00-00 FROM user |
After FROM user:
Code:
SELECT YEAR(NOW())-AVG(YEAR(birthday)) AS avgage FROM user WHERE birthday != 0000-00-00 I think it may be because we are excluding the the unset year cells but the total rows aren't changing when the average is calculated. |
could someone answer me please!
Thanks! |
Code:
SELECT YEAR(NOW())-AVG(YEAR(birthday)) AS avgage FROM user WHERE YEAR(birthday) <> 0 |
[QUOTE]Originally posted by freddie
Code:
SELECT YEAR(NOW())-AVG(YEAR(birthday)) AS avgage FROM user WHERE YEAR(birthday) <> 0 |
All times are GMT. The time now is 11:16 AM. |
Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2025, vBulletin Solutions Inc.
X vBulletin 3.8.12 by vBS Debug Information | |
---|---|
|
|
![]() |
|
Template Usage:
Phrase Groups Available:
|
Included Files:
Hooks Called:
|