The Arcive of Official vBulletin Modifications Site.It is not a VB3 engine, just a parsed copy! |
|
#1
|
||||
|
||||
I'd like to compute the average age of my users for statistical information.
Any ideas on how to write this query? |
#2
|
||||
|
||||
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; |
#3
|
||||
|
||||
How can I eliminate the ones that didn't input a year?
|
#4
|
|||
|
|||
wow sweet!
Where would I put this code and where would I recieve the results! |
#5
|
||||
|
||||
[QUOTE]Originally posted by pgowder
How can I eliminate the ones that didn't input a year? |
#6
|
||||
|
||||
Here is what I tried:
[QUOTE]SELECT YEAR(NOW())-AVG(YEAR(birthday)) AS avgage WHERE birthday != 0000-00-00 FROM user |
#7
|
||||
|
||||
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. |
#8
|
|||
|
|||
could someone answer me please!
Thanks! |
#9
|
||||
|
||||
Code:
SELECT YEAR(NOW())-AVG(YEAR(birthday)) AS avgage FROM user WHERE YEAR(birthday) <> 0 |
#10
|
||||
|
||||
[QUOTE]Originally posted by freddie
Code:
SELECT YEAR(NOW())-AVG(YEAR(birthday)) AS avgage FROM user WHERE YEAR(birthday) <> 0 |
Thread Tools | |
Display Modes | |
|
|
X vBulletin 3.8.12 by vBS Debug Information | |
---|---|
|
|
More Information | |
Template Usage:
Phrase Groups Available:
|
Included Files:
Hooks Called:
|