Home » RDBMS Server » Server Administration » Urgent! How can I create view witch do calculates a sum
Urgent! How can I create view witch do calculates a sum [message #373511] Fri, 20 April 2001 04:20 Go to next message
Karri Lahtela
Messages: 16
Registered: November 2000
Junior Member
Hi

I have a table where I have Part_No and qty (positive value for income and negative value for output). How can I create a view where I calculate sum of input and output for each part_no??

BR Karri
Re: Urgent! How can I create view witch do calculates a sum [message #373512 is a reply to message #373511] Fri, 20 April 2001 04:43 Go to previous message
Thirumalai and Prakash
Messages: 23
Registered: March 2001
Junior Member
Hi Karri,

Try this,

CREATE VIEW view_name as SELECT Part_no,SUM(DECODE(SIGN(qty),1,qty)),SUM(DECODE(SIGN(qty),-1,qty)) FROM Table_name GROUP BY part_no;

Hope it helps !

Regards
S.Thirumalai
Previous Topic: Urgent! How can I create view witch do calculates a sum
Next Topic: One step more
Goto Forum:
  


Current Time: Sat Jun 29 00:23:32 CDT 2024