Click here to Skip to main content
15,357,293 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I have database containing all info Table wise about their order like

quantity Item TableNo

1 Tikki-chat 1
1 Dal 1
1 Tikki 1
1 Samosa 1
1 samosa 1
1 Tikki 1


Now I want the Information as


quantity Item TableNo

3 Tikki-chat 1
1 Dal 1
1 Tikki 1
2 Samosa 1

How Can I do This in C#

What I have tried:

I do'not not have idea regarding this..
Posted
Updated 23-Mar-22 0:31am
Comments
Richard MacCutchan 23-Mar-22 6:34am
   
Your results do not match your data. You have only one Tikki-chat, but two Tikkis.

1 solution

We can't help: we have no idea where the "3 Tikki-chat"s come from - there is only one in your input data, and we have no idea why it should be counted three times, or "Tikki" once when there are two of them.

If your output should be this:
quantity Item TableNo
1        Tikki-chat      1
1        Dal             1
2        Tikki           1
2        Samosa          1
Then that needs an Sql GROUP BY clause, something like this:
SQL
SELECT SUM(Quantity), Item, TableNo
FROM MyTable
GROUP BY Item, TableNo
But if it isn't, then we have no idea.
   

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