Search code examples
sqlgoogle-bigquerypopsql

Trying to find all of whiskey sales from a certain store -SQL-


I want to find the total sales of Whiskeys at a certain store in the dataset

Here's my code (Using PopSql connected to bigquery)

SELECT DISTINCT category_name, ROUND(SUM(sale_dollars)) AS Total_Revenue FROM Liquor_Sales.Iowa WHERE store_name = 'HY-VEE #3 / BDI / DES MOINES' AND category_name LIKE '%WHISK%' GROUP BY category_name ORDER BY Total_Revenue DESC;

This code gives me every category that contains 'Whisk' (I.E. Canadian whiskey, Tennessee whiskey, ETC) and their total sales but I want them to be lumped into one 'Whiskey' category with the Total revenue


Solution

  • Then you simply remove the category grouping:

    SELECT
        'Whiskey' AS Category_Name,
        ROUND(SUM(sale_dollars)) AS Total_Revenue
    FROM
        Liquor_Sales.Iowa
    WHERE
        store_name = 'HY-VEE #3 / BDI / DES MOINES'
        AND 
        category_name LIKE '%WHISK%'