SQL Clone
SQLServerCentral is supported by Redgate
 
Log in  ::  Register  ::  Not logged in
 
 
 


How to sum values based on HSN codes in mssql2000


How to sum values based on HSN codes in mssql2000

Author
Message
raghuldrag
raghuldrag
SSCrazy
SSCrazy (2.4K reputation)SSCrazy (2.4K reputation)SSCrazy (2.4K reputation)SSCrazy (2.4K reputation)SSCrazy (2.4K reputation)SSCrazy (2.4K reputation)SSCrazy (2.4K reputation)SSCrazy (2.4K reputation)

Group: General Forum Members
Points: 2402 Visits: 573
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
Lynn Pettis
Lynn Pettis
SSC Guru
SSC Guru (352K reputation)SSC Guru (352K reputation)SSC Guru (352K reputation)SSC Guru (352K reputation)SSC Guru (352K reputation)SSC Guru (352K reputation)SSC Guru (352K reputation)SSC Guru (352K reputation)

Group: General Forum Members
Points: 352369 Visits: 41673
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.

Cool
Lynn Pettis

For better assistance in answering your questions, click here
For tips to get better help with Performance Problems, click here
For Running Totals and its variations, click here or when working with partitioned tables
For more about Tally Tables, click here
For more about Cross Tabs and Pivots, click here and here
Managing Transaction Logs

SQL Musings from the Desert Fountain Valley SQL (My Mirror Blog)
raghuldrag
raghuldrag
SSCrazy
SSCrazy (2.4K reputation)SSCrazy (2.4K reputation)SSCrazy (2.4K reputation)SSCrazy (2.4K reputation)SSCrazy (2.4K reputation)SSCrazy (2.4K reputation)SSCrazy (2.4K reputation)SSCrazy (2.4K reputation)

Group: General Forum Members
Points: 2402 Visits: 573
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
J Livingston SQL
J Livingston SQL
SSC-Forever
SSC-Forever (41K reputation)SSC-Forever (41K reputation)SSC-Forever (41K reputation)SSC-Forever (41K reputation)SSC-Forever (41K reputation)SSC-Forever (41K reputation)SSC-Forever (41K reputation)SSC-Forever (41K reputation)

Group: General Forum Members
Points: 41716 Visits: 41761
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

Lynn Pettis
Lynn Pettis
SSC Guru
SSC Guru (352K reputation)SSC Guru (352K reputation)SSC Guru (352K reputation)SSC Guru (352K reputation)SSC Guru (352K reputation)SSC Guru (352K reputation)SSC Guru (352K reputation)SSC Guru (352K reputation)

Group: General Forum Members
Points: 352369 Visits: 41673
I agree, that's why I wanted to see the expected results.

Cool
Lynn Pettis

For better assistance in answering your questions, click here
For tips to get better help with Performance Problems, click here
For Running Totals and its variations, click here or when working with partitioned tables
For more about Tally Tables, click here
For more about Cross Tabs and Pivots, click here and here
Managing Transaction Logs

SQL Musings from the Desert Fountain Valley SQL (My Mirror Blog)
raghuldrag
raghuldrag
SSCrazy
SSCrazy (2.4K reputation)SSCrazy (2.4K reputation)SSCrazy (2.4K reputation)SSCrazy (2.4K reputation)SSCrazy (2.4K reputation)SSCrazy (2.4K reputation)SSCrazy (2.4K reputation)SSCrazy (2.4K reputation)

Group: General Forum Members
Points: 2402 Visits: 573
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
John Mitchell-245523
John Mitchell-245523
SSC Guru
SSC Guru (121K reputation)SSC Guru (121K reputation)SSC Guru (121K reputation)SSC Guru (121K reputation)SSC Guru (121K reputation)SSC Guru (121K reputation)SSC Guru (121K reputation)SSC Guru (121K reputation)

Group: General Forum Members
Points: 121242 Visits: 18756
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

Lynn Pettis
Lynn Pettis
SSC Guru
SSC Guru (352K reputation)SSC Guru (352K reputation)SSC Guru (352K reputation)SSC Guru (352K reputation)SSC Guru (352K reputation)SSC Guru (352K reputation)SSC Guru (352K reputation)SSC Guru (352K reputation)

Group: General Forum Members
Points: 352369 Visits: 41673
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?

Cool
Lynn Pettis

For better assistance in answering your questions, click here
For tips to get better help with Performance Problems, click here
For Running Totals and its variations, click here or when working with partitioned tables
For more about Tally Tables, click here
For more about Cross Tabs and Pivots, click here and here
Managing Transaction Logs

SQL Musings from the Desert Fountain Valley SQL (My Mirror Blog)
aaron.reese
aaron.reese
SSChampion
SSChampion (10K reputation)SSChampion (10K reputation)SSChampion (10K reputation)SSChampion (10K reputation)SSChampion (10K reputation)SSChampion (10K reputation)SSChampion (10K reputation)SSChampion (10K reputation)

Group: General Forum Members
Points: 10196 Visits: 1048
@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 Sad
Go


Permissions

You can't post new topics.
You can't post topic replies.
You can't post new polls.
You can't post replies to polls.
You can't edit your own topics.
You can't delete your own topics.
You can't edit other topics.
You can't delete other topics.
You can't edit your own posts.
You can't edit other posts.
You can't delete your own posts.
You can't delete other posts.
You can't post events.
You can't edit your own events.
You can't edit other events.
You can't delete your own events.
You can't delete other events.
You can't send private messages.
You can't send emails.
You can read topics.
You can't vote in polls.
You can't upload attachments.
You can download attachments.
You can't post HTML code.
You can't edit HTML code.
You can't post IFCode.
You can't post JavaScript.
You can post emoticons.
You can't post or upload images.

Select a forum








































































































































































SQLServerCentral


Search