-
Notifications
You must be signed in to change notification settings - Fork 0
Open
Description
-- Create the sales table
CREATE TABLE sales (
id INTEGER PRIMARY KEY,
year DATE,
region VARCHAR (50),
amount DECIMAL(10, 2)
);
-- Insert sample data
INSERT INTO
sales (id, year, region, amount)
VALUES
(1, '2023-01-01', 'North', 15000.00),
(2, '2023-01-01', 'North', 22000.00),
(3, '2023-01-01', 'South', 18000.00),
(4, '2023-01-01', 'South', 12000.00),
(5, '2023-01-01', 'East', 25000.00),
(6, '2023-01-01', 'West', 19000.00),
(7, '2024-01-01', 'North', 28000.00),
(8, '2024-01-01', 'North', 31000.00),
(9, '2024-01-01', 'South', 21000.00),
(10, '2024-01-01', 'South', 16000.00),
(11, '2024-01-01', 'East', 33000.00),
(12, '2024-01-01', 'East', 29000.00),
(13, '2024-01-01', 'West', 24000.00),
(14, '2024-01-01', 'West', 27000.00);
-- Create a view with measures
CREATE VIEW sales_v AS
SELECT
year,
region,
SUM(amount) AS MEASURE revenue,
COUNT(*) AS MEASURE order_count
FROM
sales;
SEMANTIC
select
region,
AGGREGATE(revenue) AT (ALL region VISIBLE)
FROM
sales_v
WHERE
year between date '2023-01-01' and date '2025-01-01';
If you don't include the date keyword, there is not an error.
Metadata
Metadata
Assignees
Labels
No labels