SQL Query Show Customers Orders, SUM for products

Questions about the MySQL, PostgreSQL, and most other databases, as well as using it with PHP can be asked here.

Moderator: General Moderators

Post Reply
j.smith1981
Forum Newbie
Posts: 7
Joined: Mon Apr 06, 2009 3:48 pm

SQL Query Show Customers Orders, SUM for products

Post by j.smith1981 »

Hi,

I have a problem I just cant seem to get my head around to create the SQL for.

Basically all I want is this:

A list of a users products ordered.

Showing each product individually.

Like so (excuse for the crude example but this is what I am essentially looking for:

Code: Select all

 
Username (of customer)  Customer Name   Order no        Vendor code Qty     Date Ordered
jsmith1981                    Jez                   1                  123              1       13/08/09
                                                         2                   124              2      13/08/09
                                                         2                   125              6      13/08/09
 
harry                           Harry               20                  120              7      08/08/09
                                                        20                  110             2       08/08/09
 
You can use the order id if required but at the very least this example must include listing the orders by username!

I did an example like this thats required at University but for the life of me cant remember how to do this.

Thanks for helping in advance,
Jeremy.
Post Reply