Home » Developer & Programmer » Forms » HOW I CAN DO THIS ?
HOW I CAN DO THIS ? [message #302965] Wed, 27 February 2008 08:02 Go to next message
j1968s
Messages: 7
Registered: January 2008
Junior Member
CAN I DO ONE SELECT STATMENT FROM THIS :

select sum(qui) where stock = '0'
sum(qui) where stock = '1'
sum(qui) where stock = '2'
sum(qui) where stock = '3'
sum(qui) where stock = '4'
sum(qui) where stock = '5'
sum(qui) where stock = '6'
sum(qui) where stock = '7'

from transaction [/SQL]

??????????????
with thanks
JALAL
Re: HOW I CAN DO THIS ? [message #302969 is a reply to message #302965] Wed, 27 February 2008 08:09 Go to previous messageGo to next message
MarcS
Messages: 312
Registered: March 2007
Location: Antwerp
Senior Member
Have a look at the GROUP BY-clause
Re: HOW I CAN DO THIS ? [message #303008 is a reply to message #302965] Wed, 27 February 2008 10:07 Go to previous messageGo to next message
azamkhan
Messages: 548
Registered: August 2005
Senior Member
I think you can use UNION

Regards,
Azam Khan
icon3.gif  Re: HOW I CAN DO THIS ? [message #303038 is a reply to message #302965] Wed, 27 February 2008 13:46 Go to previous messageGo to next message
doss_arun
Messages: 10
Registered: February 2008
Location: iselin, new jersey
Junior Member

hi

u can , by using the GROUP BY ( its unlimited one & multi row) like below

SELECT stock, SUM ( qui ) qui
FROM transaction
GROUP BY stock


OR use the DECODE ( but its have limit & single row)

SELECT SUM ( DECODE ( stock, 0, qui, 0 ) ) stock_0,
SUM ( DECODE ( stock, 1, qui, 0 ) ) stock_1,
SUM ( DECODE ( stock, 2, qui, 0 ) ) stock_2,
SUM ( DECODE ( stock, 3, qui, 0 ) ) stock_3,
...........
SUM ( DECODE ( stock, 3, 0, qui ) ) stock_else
FROM transactions
Re: HOW I CAN DO THIS ? [message #303421 is a reply to message #302965] Fri, 29 February 2008 05:55 Go to previous messageGo to next message
Flash
Messages: 34
Registered: February 2008
Member
I would prefer this to summarize

SELECT stock, SUM ( qui ) qui
FROM transaction
GROUP BY stock



I would prefer this for reporting

SELECT SUM ( DECODE ( stock, 0, qui, 0 ) ) stock_0,
SUM ( DECODE ( stock, 1, qui, 0 ) ) stock_1,
SUM ( DECODE ( stock, 2, qui, 0 ) ) stock_2,
SUM ( DECODE ( stock, 3, qui, 0 ) ) stock_3,
...........
SUM ( DECODE ( stock, 3, 0, qui ) ) stock_else
FROM transactions

Thanks
Flash
Re: HOW I CAN DO THIS ? [message #303695 is a reply to message #303038] Sun, 02 March 2008 02:03 Go to previous messageGo to next message
j1968s
Messages: 7
Registered: January 2008
Junior Member
MANY THANKS FOR ALL
I WOULD LIKE TO ASK IF THE DECODE CAN TAKE TOW CONDITION OR NOT AS THE IF STATMENT (IF EMPNO = 700 AND DEPTNO = 10 THEN ) HOW CAN DO THIS IN DECODE ? DECODE (EMPNO AND DEPTNO ) ?

REALLY MANY THANKS.

JALAL
Re: HOW I CAN DO THIS ? [message #303707 is a reply to message #302965] Sun, 02 March 2008 03:55 Go to previous message
MarcS
Messages: 312
Registered: March 2007
Location: Antwerp
Senior Member
There is nothing wrong with doing a bit of searching on the net, or reading some manuals (for the latter there is even a very nice acryonym Wink )

Have a look here to read what you can do (or can't do) with DECODE
Previous Topic: Does any one can give me demos of oracle forms6i?
Next Topic: Run a report in web layout
Goto Forum:
  


Current Time: Sun Dec 04 21:07:19 CST 2016

Total time taken to generate the page: 0.08744 seconds