Skip to content
Advertisement

Tag: aggregate-functions

I tried solving this problem by using MAX function but get the result . Is there a way to solve it by using any other function?

I need to get “second updated_time” for each order and sorting them by “update_time”. I wrote the following query, which is not giving any output. Suppose, we have to calculate get the time difference between second updated time and first updated time against each order_id ,if we sort the table on update_time (same question but extended) Server is Mysql. The

SQL – An aggregate may not appear in the WHERE clause unless it is in a subquery contained in a HAVING clause

If you see the picture below, I only want to see those categories where the average revenue is greater than the overall average. The query that I’m using is below. The very last line is causing the issue. The error that I’m getting is: An aggregate may not appear in the WHERE clause unless it is in a subquery contained

Making cumulative sum with ids and dates in MySQL

Imagine I have this: id transactiondate transactiontag clientid transactionvalue 1 2020-12-28 pizza 0 29.99 2 2020-12-29 payment 0 -39.99 3 2020-12-28 cheese 0 -109.99 4 2020-12-28 cheese 0 -109.99 5 2020-12-28 pizza 1 -19.99 6 2020-12-28 cheese 1 -18.99 7 2020-12-28 salary 1 58.99 8 2020-12-29 salary 1 38.99 So I have all the Ids of transactions, when they were

Advertisement