Click here to Skip to main content
15,897,315 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
C#
Dear All.

I developed a POS system to sell goods in a supermarket using Visual studio C# and crystal report for receipt generation and reports. My problem is this, when i try to print daily sales, it prints all sales as it is in the database all i want is to sum up of a particular item sold together e.g if i sold 10 bottles of coke to different customers its showing it one by one by sales but i want it to sum it up to be 10 instead of listing it one by one as it is sold.


What I have tried:

I dont know how to go about it
Posted
Updated 9-Jun-16 5:54am

1 solution

Read up on how to use SUM in queries :
SQL SUM() Function[^]
SQL SUM Function[^]
SQL: SUM Function[^]
 
Share this answer
 
Comments
Member 12414126 9-Jun-16 12:16pm    
How can i use this in crystal report?
Mehdi Gholam 9-Jun-16 12:34pm    
Crystal Report generates reports from data queries, just edit the query for your report.
Member 12414126 9-Jun-16 12:37pm    
I tried to write this line of query but i get and error saying incorrect syntax near the key word 'where'

public DataSet Dailysales(string date)
{

DataSet ds = new DataSet();
string sql = "select Itemname, SUM(QntSold) from POS GROUP BY Itemname where Date ='" + Convert.ToDateTime(date) + "'";
SqlDataAdapter dadbt = new SqlDataAdapter(sql, mycon.Opencon());
dadbt.Fill(ds);
dadbt.Dispose();
return ds;

}
Mehdi Gholam 9-Jun-16 12:43pm    
WHERE clause go before GROUP BY
Member 12414126 9-Jun-16 12:52pm    
it only displayed only the itemname the QntSOld and total amount value did nit show on the crystal report

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900