ramachandran.123
Starting Member
3 Posts |
Posted - 2012-12-10 : 04:18:09
|
Dear SirI have written sql query select INVOICE.InvoiceTypeCode, INVOICE.TarrifHeadNumber,CETSH.GoodsDescription, INVOICETYPEMASTER.InvoiceTypeName, INVOICEITEMS.ItemQuantity as SumQuantity, INVOICE.BasicValue ,INVOICE.BasicValue * INVOICE.ExchangeRate + INVOICECHARGES.ChargesValue*INVOICE.ExchangeRate as AssValue, INVOICE.ExcemptionNumber,Invoice.ExcemptionNotificationSerialNo, CHARGESMASTER.ChargesPercentage,INVOICECHARGES.ChargesValue From INVOICE, INVOICEITEMS, INVOICECHARGES, CETSH, INVOICETYPEMASTER,CHARGESMASTER Where INVOICETYPEMASTER.InvoiceTypeCode=INVOICE.InvoiceTypeCode And cast(CETSH.CETSHNumber as varchar)=INVOICE.TarrifHeadNumber And INVOICECHARGES.InvoiceNumber=INVOICE.InvoiceNumber AND INVOICECHARGES.FinYearCode=INVOICE.FinYearCode AND INVOICECHARGES.BranchCode=INVOICE.BranchCode And INVOICECHARGES.TaxPaymentType=1 And CHARGESMASTER.DutyHeadCode=5 And INVOICEITEMS.InvoiceNumber=INVOICE.InvoiceNumber AND INVOICEITEMS.FinYearCode=INVOICE.FinYearCode AND INVOICE.BranchCode=INVOICEITEMS.BranchCode And (INVOICE.InvoiceTypeCode=1 or INVOICE.InvoiceTypeCode=2) And month(INVOICE.InvoiceDate)='11' And year(INVOICE.InvoiceDate)='2012' And INVOICE.BranchCode=1001 Group by INVOICE.InvoiceTypeCode, INVOICE.TarrifHeadNumber, CETSH.GoodsDescription, INVOICETYPEMASTER.InvoiceTypeName, CHARGESMASTER.ChargesPercentage,INVOICECHARGES.ChargesValue, INVOICE.ExcemptionNumber,Invoice.ExcemptionNotificationSerialNo, INVOICE.BasicValue, invoice.exchangerate,INVOICEITEMS.ItemQuantity Order by INVOICE.InvoiceTypeCode desc, INVOICE.TarrifHeadNumberI am getting 2 records2 85433000 85433000 DOMESTIC 2.00 98000.00 98000.0000 010/1997 DT: 01.03.1997 1 12.00 .002 85433000 85433000 DOMESTIC 1.00 230000.00 230000.0000 010/1997 DT: 01.03.1997 1 12.00 .00Amount is 328000 and quantity 3If i use sum by in sql serverlike select INVOICE.InvoiceTypeCode, INVOICE.TarrifHeadNumber,CETSH.GoodsDescription, INVOICETYPEMASTER.InvoiceTypeName, sum(INVOICEITEMS.ItemQuantity) as SumQuantity, sum(INVOICE.BasicValue * INVOICE.ExchangeRate + INVOICECHARGES.ChargesValue*INVOICE.ExchangeRate) as AssValue, INVOICE.ExcemptionNumber,Invoice.ExcemptionNotificationSerialNo, CHARGESMASTER.ChargesPercentage,INVOICECHARGES.ChargesValue From INVOICE, INVOICEITEMS, INVOICECHARGES, CETSH, INVOICETYPEMASTER,CHARGESMASTER Where INVOICETYPEMASTER.InvoiceTypeCode=INVOICE.InvoiceTypeCode And cast(CETSH.CETSHNumber as varchar)=INVOICE.TarrifHeadNumber And INVOICECHARGES.InvoiceNumber=INVOICE.InvoiceNumber AND INVOICECHARGES.FinYearCode=INVOICE.FinYearCode AND INVOICECHARGES.BranchCode=INVOICE.BranchCode And INVOICECHARGES.TaxPaymentType=1 And CHARGESMASTER.DutyHeadCode=5 And INVOICEITEMS.InvoiceNumber=INVOICE.InvoiceNumber AND INVOICEITEMS.FinYearCode=INVOICE.FinYearCode AND INVOICE.BranchCode=INVOICEITEMS.BranchCode And (INVOICE.InvoiceTypeCode=1 or INVOICE.InvoiceTypeCode=2) And month(INVOICE.InvoiceDate)='11' And year(INVOICE.InvoiceDate)='2012' And INVOICE.BranchCode=1001 Group by INVOICE.InvoiceTypeCode, INVOICE.TarrifHeadNumber, CETSH.GoodsDescription, INVOICETYPEMASTER.InvoiceTypeName, CHARGESMASTER.ChargesPercentage,INVOICECHARGES.ChargesValue, INVOICE.ExcemptionNumber,Invoice.ExcemptionNotificationSerialNo Order by INVOICE.InvoiceTypeCode desc, INVOICE.TarrifHeadNumber2 85433000 85433000 DOMESTIC 9.00 984000.0000 010/1997 DT: 01.03.1997 1 12.00 .00I am getting different amount 984000.0000 and quantity 9.Please help me to fix the issueThanks and RegardsN.Ram |
|