php - Mysql Query: error that says subquery returns more than 1 row -


i trying complex query 2 tables...it's question skill quiz.

table

**orders                                    customer**s     id                                         id     date                                     first_name     shipping_amount                          last_name      order_status                             city     customer_id (customers.id)             state  

output

-----------+------------+ | state     |  # orders  | +-----------+------------+ | ny        |  55        | | ca        |  40        | | nj        |  33        | | fl        |  21        | | mo        |  12        | +-----------+------------+ 

i have been working on query , looks this...

select distinct state, (select count(id) orders                         customers                         group state                         order orders desc) customers 

it gave me error says subquery returns more 1 row

try this:

select c.state, count(o.id) orders  customers c, orders o  o.customer_id = c.id  group state  order orders desc 

the sub query isn't necessary.


Comments

Popular posts from this blog

c++ - How do I get a multi line tooltip in MFC -

asp.net - In javascript how to find the height and width -

c# - DataTable to EnumerableRowCollection -