This topic is locked

Total expend from Orders Table

10/19/2007 9:50:03 AM
PHPRunner General questions
B
bannero author

Hello,
I just found about this great software, and need a little help to start.
I have two tables I need information from:

How do I get a report with a total expend by customer table from orders table
Thanks

Sergey Kornilov admin 10/19/2007

I guess you talking about a JOIN SQL query that pulls data from two tables at once.

Select ID,

OrderDate,

CustomerID,

b.ID as DetailID,

b.Quantity as ProductQuantity

from OrderHeader a

inner join OrderDetail b on

a.ID = b.OrderID



More info:

http://www.xlinesoft.com/phprunner/docs/sql_query_page.htm

B
bannero author 10/19/2007

Hello Sergey,
Thanks for your prompt reply,

I guess I did not give you enough information:
I have four tables: User, customers, Orders, Merchant

Every user has his own customers I want them to see only his customers total dollar amount expend, with like a dropdown to select a customer to see the total dollar amount expend by that customer and field with the dollar amount not expend left in customer account.
select `UserId`,

`GroupID`,

`wordPass`,

`UserSince`,

`Name`,

`LastName`,

`Phone`,

`email`,

`Notes`

From `users`
select `CustomerId`,

`UserId`,

`CustomerSince`,

`Name`,

`LastName`,

`Phone`,

`email`,

`InitialDollarAmount`,

`Notes`

From `customer`
select `OrderId`,

`UserId`,

`CustomerId`,

`MerchantID`,

`Amount`,

`Date`,

`Notes`

From `orders`
select `MerchantID`,

`MerchantName`,

`MerchantWeb`,

`Phone`,

`Notes`

From `merchant`