Screen Link: https://app.dataquest.io/m/465/building-and-organizing-complex-queries/4/creating-views
My Code: <
CREATE VIEW chinook.customer_gt_90_dollars AS
SELECT
c.*
FROM chinook.customer c
INNER JOIN chinook.invoice i ON i.customer_id = c.customer_id
GROUP BY c.* HAVING SUM(i.total) > 90;
What I expected to happen:
While following the instructions to create a VIEW in this mission ( where the view should contain ALL columns from a table) I tried to use the name alias for the table in GROUP BY as my code shows above. But I get the following error. The answer code seems to use a shortcut i.e GROUP BY 1 . It makes me wonder why GROUP BY doesn’t like the table name alias followed by * and likes only the numbered shortcut in this case. I even tried using parenthesis around it like this : (c.*) but still get the error. Appreciate clarifying if it’s a syntax rule or something else I need be aware of. Thanks much.
What actually happened:
(sqlite3.OperationalError) near "*": syntax error
[SQL: CREATE VIEW chinook.customer_gt_90_dollars AS SELECT c.* FROM chinook.customer c INNER JOIN chinook.invoice i ON i.customer_id = c.customer_id GROUP BY c.* HAVING SUM(i.total) > 90;]