Jump to content

help building sql statement


l0ve2hat3

Recommended Posts

I need compare two tables.

 

first table-  [invoice] and contains a row named [total_price] and [invoice_Number]

 

second table- [invoice_Itemized] contains [PricePer], [Qty] and [invoice_Number]

 

here is a same of the [invoice] table

 

column:[invoice_Number]-[Total_Price]

value:             1                  10.00

 

here is a same of the [invoice_itemized] table

 

column: [invoice_Number]-[PricePer]-[Qty]

value:             1                  2.00       1

value:             1                  2.00       1

value:             1                  2.00       1

value:             1                  2.00       1

value:             1                  2.00       1

 

 

what i want to do is show the total of [invoice].[Total_Price] and the total of ([invoice_Itemized].[PricePer]*[invoice_Itemized].[Qty]) to compare

 

I came up with

 

SELECT SUM( [invoice].[Total_Price] ) as Total_Price,SUM( [invoice_Itemized].[PricePer]*[invoice_Itemized].[Qty] ) as Itemized_Price FROM [invoice] LEFT JOIN [invoice_Itemized] ON [invoice_Itemized].[invoice_Number]=[invoice].[invoice_Number] 

 

Link to comment
https://forums.phpfreaks.com/topic/115051-help-building-sql-statement/
Share on other sites

what i want to do is show the total of [invoice].[Total_Price] and the total of ([invoice_Itemized].[PricePer]*[invoice_Itemized].[Qty]) to compare

 

EDIT***

 

what i want to do is show the total of [invoice].[Total_Price] and the total of ([invoice_Itemized].[PricePer]*[invoice_Itemized].[Qty]) to compare for each row in the [invoice] table

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.