Skip to content
Advertisement

Tag: aggregate-functions

How to get a COUNT() value when GROUP BY has no row?

RDMS : MariaDB 10.1.23 MCRE : SQLFiddle: http://sqlfiddle.com/#!9/f32a01/1 Consider the following query : Without the GROUP BY clause, I know that COUNT() will return 0 if no row match the query. I also know that, if my GROUP BY “fails” (If i have no row to group by, in my example, if no row satisfy e.created_at > CURRENT_DATE – INTERVAL

Get the average of values in every specific epoch ranges in unix timestamp which returns -1 in specific condition in MySQL

I have a MySQL table which has some records as follows: I want to compute the average for every 10 epochs to see the following results: I saw some similar answers like enter link description here and enter link description here and enter link description here but these answers are not a solution for my specific question. How can I

calculating percentage on multiple sql tables

There are 2 tables mobile and web Table name: Mobile Table name: web I need to calculate percentage of users who only visited : mobile, web and both. That is, the percentage of users who are only in the mobile table, only in the web table and in both tables. The sum should be 1. I tried using union but

Weighted Average of Survey Questions

I have to calculate weighted average for all questions. Assuming there are 22 questions in a survey which has 5 options as 1,2,3,4,5 and NA. For example, 3 people took the survey (all 22 question) Assuming there are 10 NA responses (combined for all 3). So, denominator will be : 22*3 – 10 = 56 Numerator will be : 1*X1

Advertisement