Search code examples
c#sqlselect-query

Complex SELECT Query Format for C# Form


I have a table with the following columns:

SupplierId
SupplierBillID
SupplierDate
Supplierparticulars
SupplierCredit
SupplierDebit

Now, the problem is that earlier I had only 1 particulars in 1 bill. Now I have more particulars in the bill and since the application is running for a long time I am not in a condition to change it. What it shows right now is like:

SupplierBillID  SupplierParticulars       SupplierCredit      SupplierDebit
17                 Pipes                      1500                   0
17                 Tubes                       500                   200
17                 Wire                       1000                   500

But instead I want it to show like:

17                 **See Details**               3000                   700

Now this "See Details" thing I can set in gridviewCellclick event to show the details of that bill and all particulars.


Solution

  • select SupplierBillID, 'See Details', sum(SupplierCredit), sum(SupplierDebit)
    from your_table
    group by SupplierBillID