Subject Re: [firebird-support] Doubt Regarding Sum() Function
Author Daniel Rail
Hi,

At September-14-10, 9:40 AM, Vishal Tiwari wrote:

> Hi,
>  
> Required result is as follows:
>  
> Book_Name   Book_Price   Copy_Sold
> ABC               1250.00          1130
> LMN               5698.00          240
> PQR               1524.00          1972
>  

Then your query should be:

Select
BM.Book_Name,
BM.Book_Price,
Sum(COPY_SOLD) As COPY_SOLD
from Book_Master BM
Join Book_Details BD On BM.Book_Name = BD.Book_Name
Where BD.YearMonth = '200904'
Group By BM.Book_Name, BM.Book_Price

Or, it can also be:

Select
BM.Book_Name,
BM.Book_Price,
(select Sum(BD.COPY_SOLD)
from Book_Details BD
where BM.Book_Name = BD.Book_Name
and BD.YearMonth = '200904') As COPY_SOLD
from Book_Master
order by BM.Book_Name


--
Best regards,
Daniel Rail
Senior Software Developer
ACCRA Solutions Inc. (www.accra.ca)
ACCRA Med Software Inc. (www.filopto.com)