brainy-raincoat-5393
01/31/2023, 3:00 PMsales_in_latest
CREATE VIEW sales_of_products AS
SELECT product_id,
COUNT(*) totalCnt,
SUM(case when SUBSTR(orders.order_date,1,7) = '2023-01' then 1 END) sMM01,
SUM(case when SUBSTR(orders.order_date,1,7) = '2022-12' then 1 END) sMM12,
SUM(case when SUBSTR(orders.order_date,1,7) = '2022-11' then 1 END) sMM11,
SUM(case when SUBSTR(orders.order_date,1,7) = '2022-10' then 1 END) sMM10,
SUM(case when SUBSTR(orders.order_date,1,7) = '2022-09' then 1 END) sMM09,
SUM(case when SUBSTR(orders.order_date,1,7) = '2022-08' then 1 END) sMM08,
SUM(case when SUBSTR(orders.order_date,1,7) = '2022-07' then 1 END) sMM07,
SUM(case when SUBSTR(orders.order_date,1,7) = '2022-03' then 1 END) sMM03,
SUM(case when SUBSTR(orders.order_date,1,7) = '2022-04' then 1 END) sMM04,
SUM(case when SUBSTR(orders.order_date,1,7) = '2022-05' then 1 END) sMM05,
SUM(case when SUBSTR(orders.order_date,1,7) = '2022-06' then 1 END) sMM06
FROM order_skus
JOIN orders ON orders.id = order_skus.order_id
WHERE orders.status NOT IN ('prepared_wx_prepay', 'failed', 'wait_pay', 'user_cancel', 'system_cancel')
GROUP BY order_skus.product_id
when query this view in md file, error like this:
my-evidence-project@0.0.1 dev
evidence dev -oSvelteKit v1.0.0-next.202 network: not exposed network: not exposed local: http://localhost:3000 Use --host to expose server to other devices on this network ✓ orders_by_month from database ✓ orders_of_last_month from database ✓ orders_of_this_month from database sales_in_latest running... D:\Users\james\evidence>
brainy-raincoat-5393
01/31/2023, 3:05 PMgreat-boots-39022
brainy-raincoat-5393
01/31/2023, 3:28 PMgreat-boots-39022
brainy-raincoat-5393
01/31/2023, 3:34 PMgreat-boots-39022
CREATE VIEW sales_of_products AS
brainy-raincoat-5393
01/31/2023, 3:43 PMCREATE VIEW sales_of_products AS
in duckdb,
in Evidence
SELECT * FROM sales_of_product ORDER BY totalCnt desc LIMIT 20
great-boots-39022
great-boots-39022
great-boots-39022
brainy-raincoat-5393
01/31/2023, 9:27 PMbrainy-raincoat-5393
01/31/2023, 9:50 PMbrainy-raincoat-5393
02/01/2023, 8:53 AMCREATE VIEW sales_of_products AS
gives execution error
CREATE TABLE sales_of_products AS
succeeds
DuckDB How did you do it?(DuckDB 너 어떻게 한거야?)great-boots-39022
CREATE VIEW
syntax and it worked. I was using DBeaver to set up the view before testing in Evidence. Two other things that might be impacting this - I'm on a Mac (I'll test on Windows next) + I wonder if the duckdb version has anything to do with itgreat-boots-39022
great-boots-39022
great-boots-39022
select item from orders
join deliveries on orders.id=deliveries.order_id
This query breaks on Windows, but works on Mac. Interestingly, changing the join to a "left join" gets the query to run on Windows, but if you then add a where clause to it, it breaks againgreat-boots-39022