我有
我在这个gridview中有一个asp网格,有很多重复的行,这些行有不同的余额细节,但id是相同的。
我想要什么
我想只显示一行具有相同ID且总余额明细,
将添加两列
查询是:
string qstr = "Select id, WalletType, sno, TransferBy, TransferTo, Credit, debit,
Balance, vdate, Description, Descid from view_transactionsummary_dealer where vdate between '" + objdl.GetDBDate(Session["fromdate"].ToString().Replace("'", "''")) + "' and '" +
objdl.GetDBDate(Session["todate"].ToString().Replace("'", "''")) + "'" and TransferBy = "Viewstate["TransferBy"]";
答案 0 :(得分:0)
如果您希望仅针对具有总余额详细信息的相同ID显示单行
然后你必须使用group by id
和SUM(total balance)
答案 1 :(得分:0)
试试这个
string qstr = " SELECT id, WalletType, sno, TransferBy, TransferTo,Credit, debit,
SUM(Balance) Over(Partitiob by id order by (select NULL)),
Count(Balance) Over(Partitiob by id order by (select NULL)),vdate,
Description, Descid
FROM view_transactionsummary_dealer
WHERE vdate Between
'" + objdl.GetDBDate(Session["fromdate"].ToString().Replace("'", "''"))
+ "' AND '" +
objdl.GetDBDate(Session["todate"].ToString().Replace("'", "''"))
+ "'" AND
TransferBy = "Viewstate["TransferBy"] Group By id,WalletType,sno,TransferBy,TransferTo,Credit, debit,vdate,Description, Descid ";