How to sum values based on HSN codes in mssql2000

  • Hi Friends,

    I have a created  one sample table and inserted some sample rows here


     create table ram
     (
     invoiceno varchar(20),
    cust_name varchar(20),
    invoice_docvalu number(10,2),
    taxable_value number(5,2),
    IGST_value number(5,2),
    CGST_value number(5,2),
    SGST_VALUE number(5,2),
     HSN varchar(20)
     )

    insert into ram values ('Inv/01-1718','HH','180','32',0,'21.6','21.6','74')
    insert into ram values ('Inv/01-1718','HH','170','28',0,'20.4','20.4','74')

    insert into ram values ('Inv/01-1718','HH','140','30',0,'16.8','16.8','54')

    insert into ram values ('Inv/01-1718','HH','160','20',0,'18.8','18.8','54')

    Expected Output is

    Based on this hsn code i Have to display summarise value of invoice_docval,IGST_Value,SGST_Value,CGST_Value ,Taxable_value

    Kindly Give suggestion

  • raghuldrag - Thursday, December 21, 2017 9:50 AM

    Hi Friends,

    I have a created  one sample table and inserted some sample rows here


     create table ram
     (
     invoiceno varchar(20),
    cust_name varchar(20),
    invoice_docvalu number(10,2),
    taxable_value number(5,2),
    IGST_value number(5,2),
    CGST_value number(5,2),
    SGST_VALUE number(5,2),
     HSN varchar(20)
     )

    insert into ram values ('Inv/01-1718','HH','180','32',0,'21.6','21.6','74')
    insert into ram values ('Inv/01-1718','HH','170','28',0,'20.4','20.4','74')

    insert into ram values ('Inv/01-1718','HH','140','30',0,'16.8','16.8','54')

    insert into ram values ('Inv/01-1718','HH','160','20',0,'18.8','18.8','54')

    Expected Output is

    Based on this hsn code i Have to display summarise value of invoice_docval,IGST_Value,SGST_Value,CGST_Value ,Taxable_value

    Kindly Give suggestion

    Based on the sample data what will the output look like.

  • my expected output is 


    invoiceno        cust_name   invoice_docvalu     taxable_value         IGST_value   CGST_value      SGST_value           HSN
    Inv/01-1718      HH                300                           50                          0                      35                   35                          54
    Inv/01-1718       HH                350                           60                        0                     43                    43                         74

    Based on HSN code i have summarise

  • use SUM with GROUP BY  invoiceno, cust_name,HSN

    ________________________________________________________________
    you can lead a user to data....but you cannot make them think
    and remember....every day is a school day

  • I agree, that's why I wanted to see the expected results.

  • Hi friends,

    That code is working if my expected output is like below what do to

    invoiceno   cust_name invoice_docvalu      taxable_value   IGST_value               CGST_value          SGST_value    HSN
    Inv/01-1718      HH      650                             50              0                    35                         35         54
    Inv/01-1718    HH      650                               60             0                    43                            43         74

    here  i have to show summarise  value of invoice_docvalu based invoiceno

  • I don't remember "number" being a data type in SQL Server 2000.  Is that really what you're using?  If it is, please post correct table DDL.

    raghuldrag - Thursday, December 21, 2017 9:40 PM

    That code is working if my expected output is like below what do to

    What code is that?  Please post the query you have tried, so that we can show you where you're going wrong.

    John

  • raghuldrag - Thursday, December 21, 2017 9:40 PM

    Hi friends,

    That code is working if my expected output is like below what do to

    invoiceno   cust_name invoice_docvalu      taxable_value   IGST_value               CGST_value          SGST_value    HSN
    Inv/01-1718      HH      650                             50              0                    35                         35         54
    Inv/01-1718    HH      650                               60             0                    43                            43         74

    here  i have to show summarise  value of invoice_docvalu based invoiceno

    What?

  • @rahoul
    How have you managed to accumulate 1234 points on your profile when you can't even SUM and GROUP BY?

    We are all for helping newbies and intermediate data wranglers but this worries me 🙁

Viewing 9 posts - 1 through 8 (of 8 total)

You must be logged in to reply to this topic. Login to reply