Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 Help on SQL Codeing

Author  Topic 

jagganaveen
Starting Member

6 Posts

Posted - 2007-08-28 : 05:22:54
Hi Friends,


I want codeing for to find (subtotal & total)the following

Input

productname qty_A_grade Qty_B_grade
abc 10 5
def 5 5
subtotal
gh 10 10
ab 10 10
Total


output

productname qty_A_grade Qty_B_grade
abc 10 5
def 5 5
subtotal 15 10
gh 10 10
ab 10 10
Total 20 20



spirit1
Cybernetic Yak Master

11752 Posts

Posted - 2007-08-28 : 05:28:11
now that's question with a complete lack of info

here's one way:

print('ename salary')
print('ravi 10')
print('kiran 20')
print('raj 10')
print('subtotal 40')
print('raju 10')
print('shiva 20')
print('Total 30')


_______________________________________________
Causing trouble since 1980
blog: http://weblogs.sqlteam.com/mladenp
Go to Top of Page

AndrewMurphy
Master Smack Fu Yak Hacker

2916 Posts

Posted - 2007-08-28 : 05:31:09
I want to win the lottery as well.....and given the amount of into you have posted to describe your problem, I don't know which one of us will hit the jackpot first.


I wonder do college terms start early these days.....looks like "SQL 101" might be starting again.
Go to Top of Page

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2007-08-28 : 05:31:51
quote:
Originally posted by jagganaveen

Hi Friends,


I want sample codeing for the following


ename salary
ravi 10
kiran 20
raj 10
subtotal 40
raju 10
shiva 20
Total 30



Where do you want to show the data?

Madhivanan

Failing to plan is Planning to fail
Go to Top of Page

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2007-08-28 : 06:03:27
quote:
Originally posted by jagganaveen

Hi Friends,


I want codeing for to find (subtotal & total)the following

Input

productname qty_A_grade Qty_B_grade
abc 10 5
def 5 5
subtotal
gh 10 10
ab 10 10
Total


output

productname qty_A_grade Qty_B_grade
abc 10 5
def 5 5
subtotal 15 10
gh 10 10
ab 10 10
Total 20 20






How are you dividing subtotal and total group data?

Madhivanan

Failing to plan is Planning to fail
Go to Top of Page

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2007-08-28 : 08:18:36
Well if you dont use front end, then read about ROLLUP Operator in sql server help file

Madhivanan

Failing to plan is Planning to fail
Go to Top of Page
   

- Advertisement -