Quantcast
Channel: VBForums
Viewing all articles
Browse latest Browse all 15463

Count number of Instances of user name if another column is not null

$
0
0
I have a database that stores information on program usage in MySQL.

Name:  database.jpg
Views: 15
Size:  14.8 KB

I use the following query to get the average duration and number of times launched by user name:

SELECT username,
COUNT('username') AS launchcount,
SUBSTRING(SEC_TO_TIME(AVG(TIME_TO_SEC(`durationtime`))), 1, 8) AS averageduration
FROM mcc3dumdb.tbleusage
WHERE 'durationtime' IS NOT Null
Group By username

Name:  results.jpg
Views: 12
Size:  8.5 KB

This works great except for one small problem. It is counting the launch of a username where the duration time is null. The user JBurt should return a count of 4 but it returns 5. How do I modify the above query to only count where a duration time is present? I can tell that it is not averaging where the duration time is null but it is counting it.
Attached Images
  

Viewing all articles
Browse latest Browse all 15463

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>