• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

SQLQuery

 
siva kumar
Ranch Hand
Posts: 86
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
MyTable look likes below one
-------------
Name | Sal
--------------
aa | 1000
bb | 3000
cc | 5000
-----------------


I want to dispaly the datas as like

-----------------------
Name | Sal | Total
-----------------------
aa | 1000 | 1000
bb | 3000 | 4000
cc | 5000 | 9000
------------------------



what is the sql query returning the above structure.
 
Shailesh Chandra
Ranch Hand
Posts: 1082
Java Oracle Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Which Database are you using , If you are using Oracle then you can use analytical functions of oracle, search the Google for same

you may make a query like



Hope this query helps you ... this is a sample query you need to make your own query

thanks
[ November 03, 2004: Message edited by: Shailesh Chandra ]
 
Adeel Ansari
Ranch Hand
Posts: 2874
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
not working Shailesh. But i am sure there must be someway out, and somebody will get you the right query for this.
 
Shailesh Chandra
Ranch Hand
Posts: 1082
Java Oracle Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have just given an idea to make query ....however it was working for me at first instance on oracle 9i

hope this URL of
Calculate a running Total will put better light.

thanks
[ November 03, 2004: Message edited by: Shailesh Chandra ]
 
Adeel Ansari
Ranch Hand
Posts: 2874
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Thanks Shailesh that link worked.
 
Shailesh Chandra
Ranch Hand
Posts: 1082
Java Oracle Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Cheers
 
siva kumar
Ranch Hand
Posts: 86
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Shailesh and Adeel
Regards
 
rakkesh kumar
Ranch Hand
Posts: 37
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
but the query is not working in MSSQLServer

.
 
Shailesh Chandra
Ranch Hand
Posts: 1082
Java Oracle Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
rakkesh ,

query uses analytical feature of oracle , hence it will work in oracle only.

it will not work in sql server untill they provide same features

thanks
 
Jeanne Boyarsky
author & internet detective
Marshal
Posts: 34648
364
Eclipse IDE Java VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Siva,
You could just add up the numbers in Java when iterating through the resultset and add the total column to the output then.
 
Adeel Ansari
Ranch Hand
Posts: 2874
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Jeanne Boyarsky:
Siva,
You could just add up the numbers in Java when iterating through the resultset and add the total column to the output then.


better approach. cent percent agreement.
this way doesn't matter if you change your db in future.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic