![]() |
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 |
That works, thanks guys!
|
Don't I rock as well? :(
|
NO, only I do!
|
hmmm......this is my result: Array :confused:
|
[QUOTE]Originally posted by freddie
NO, only I do! |
whoa, my users are old :-) (32.3151 average)
- djr oops, accidentaly clicked 'new thread' instead of 'new reply'. Please move this to https://vborg.vbsupport.ru/showthrea...threadid=33554 thanks and sorry - djr |
Aight, Thanks Firefly
|
[QUOTE]Originally posted by FireFly
Don't I rock as well? :( |
[QUOTE]Originally posted by FWC
Yeah, but I tell you and Bira "you rock" all the time. :) I don't get as many chances with Freddie. :) |
[QUOTE]Originally posted by freddie
No need. I will get enough of that when v3 is released ;) Then that will quickly be followed by "you suck, why did you change that???". |
you all rock! :rolleyes:
Could someone help me out with my question please! |
Psychdrone, add this in your index.php:
PHP Code:
|
[QUOTE]Originally posted by freddie
No need. I will get enough of that when v3 is released ;) Then that will quickly be followed by "you suck, why did you change that???". |
I get Null as an answer. Does this work for VB gold?
|
All times are GMT. The time now is 03:10 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:
|