ALTER PROCEDURE[dbo].[prctblExpenseMasterDetailsView]
(
@iAccID int,
@FromDate DateTime,
@ToDate DateTime
--@dInvoiceDate datetime
)
AS
SET NOCOUNT ON
BEGIN
SELECT
TS.iAccID as iAccID,
TS.vAccName as Name,
SUM(SI.vItemName) as Item,
SUM(SI.iNos) as Qty,
SI.deRate as Rate,
SUM(SI.deAmount) as Amount,
SUM(TS.dInvoiceDate) as Date
FROM tblSales TS INNER JOIN tblSalesItem SI ON TS.iSalesID=SI.iSalesID
where
TS.iAccID=@iAccID AND TS.dInvoiceDate>=@FromDate and dInvoiceDate<=@ToDate
END
I NEED TO SUM CERTAIN ABOVE MENTIONED COLUMNS .PLEASE GIVE CORRECT CODE WITH INNER JOIN
Loading
Maneesh A NPosted Sep 3, 2013, 4:04 AM
Column 'tblSalesItem.vItemName' is invalid in the select list because it is not contained in either an aggregate function or the GROUP BY clause.
Prasenjit DeyPosted Sep 3, 2013, 3:45 AM
(
@iAccID int,
@FromDate DateTime,
@ToDate DateTime
--@dInvoiceDate datetime
)
AS
SET NOCOUNT ON
BEGIN
SELECT
TS.dInvoiceDate Date,
SI.vItemName ItemName,
Count(SI.iNos) as Qty,
SUM(SI.deRate) as Rate,
SUM(SI.deAmount) as Amount
FROM tblSales TS INNER JOIN tblSalesItem SI ON TS.iSalesID=SI.iSalesID
where
TS.iAccID=@iAccID AND TS.dInvoiceDate>=@FromDate and dInvoiceDate<=@ToDate
group by
TS.dInvoiceDate
END
use this code
Maneesh A NPosted Sep 3, 2013, 3:36 AM
Report: Example
TEA COFFEE
Date Quntity Amount Qunatity Amount
03-09-2013 10 100 15 150
04-09-2013 11 110 16 160
Prasenjit DeyPosted Sep 3, 2013, 3:28 AM
(
@iAccID int,
@FromDate DateTime,
@ToDate DateTime
--@dInvoiceDate datetime
)
AS
SET NOCOUNT ON
BEGIN
SELECT
Count(SI.iNos) as Qty,
SUM(SI.deRate) as Rate,
SUM(SI.deAmount) as Amount,
DATEDIFF(day,@FromDate, @ToDate) as Date
FROM tblSales TS INNER JOIN tblSalesItem SI ON TS.iSalesID=SI.iSalesID
where
TS.iAccID=@iAccID AND TS.dInvoiceDate>=@FromDate and dInvoiceDate<=@ToDate
END
look at the code
Prasenjit DeyPosted Sep 3, 2013, 3:23 AM
Maneesh A NPosted Sep 3, 2013, 3:18 AM
iiSalesItemID iSalesID
iSalesID iAccID
iItemID vAccName
vItemCode dInvoiceDate
vItemName iSerialNo
iNos deTotAmount
deRate
deAmount
vAccName as Customer Name
From Date
To Date .
when i select 'Customer Name' from textbox,'from' and 'to' date from date time picker.there is print button in form.in crystal report,i need date,quantity,amount. if there are so many entries, in same day means in same date,no need to repeat that same date in report.in the same way,quantity should sum,amount should sum that i have to get in report also...so how to write SP using above Two Tables?please get me soon?briefly sum date,quantity,amount
Prasenjit DeyPosted Sep 3, 2013, 2:51 AM