Reputation: 309
I`m following and example give in Coursera course SQL for Data Science, this is the example:
Select customer_name
,customer_state
(Select Count (*) AS orders
FROM Orders
Where Orders.customer_id = Customer.customer_id) AS orders
From customers
Order By Customer_name
So I try to apply the same logic to my Chinook DB using this query:
Select FirstName
,State
(Select Count (*) As invoices
From invoices
Where invoices.CustomerId = customers.CustomerId) As Orders
From Customers
Order by Firstname
But it seems like I`m making a mistake as SQLite wont even let me run it Do you have any idea why?
Upvotes: 0
Views: 170
Reputation: 46219
Missing comma before subquery.
so the syntax will be error.
Select customer_name
,customer_state
,(Select Count (*) AS orders
FROM Orders
Where Orders.customer_id = Customer.customer_id) AS orders
From customers
Order By Customer_name
Upvotes: 3