Advanced SQL Techniques: Master the ROLLUP, CUBE AND GROUPINSETS Function

 DROP TABLE IF EXISTS Sales


-- Step 1: Create the Sales Table

CREATE TABLE Sales (

    Product VARCHAR(50),

    Region VARCHAR(50),

    Sales INT

);


-- Step 2: Insert Sample Data into the Sales Table

INSERT INTO Sales (Product, Region, Sales) VALUES ('A', 'East', 100);

INSERT INTO Sales (Product, Region, Sales) VALUES ('A', 'West', 150);

INSERT INTO Sales (Product, Region, Sales) VALUES ('B', 'East', 200);

INSERT INTO Sales (Product, Region, Sales) VALUES ('B', 'West', 250);


select * from sales

Comments

Popular posts from this blog

50 Essential SQL Questions to Land Your Dream Job

How to find all the customers who placed orders on three consecutive days | SQL Scenario questions

ACCENTURE SQL INTERVIEW QUESTION | Change the ProductIDs