Skip to content
Advertisement

Mysql where condition for single SELECT [not all]

I want to calculate the total gross amount of a CLIENT in all stores and in a specific store both in one query. Not repeating the same query twice as I did below and also not using group_by.

My tables are: Clients and Orders

Expected result:

My query is

Advertisement

Answer

SUM with CASE WHEN for given store to get gross amount for a specific store

User contributions licensed under: CC BY-SA
5 People found this is helpful
Advertisement