Home » SQL & PL/SQL » SQL & PL/SQL » sql query problem
sql query problem [message #355954] Tue, 28 October 2008 13:20 Go to next message
emrecaniaz
Messages: 3
Registered: October 2008
Junior Member
t_1
----------- source table ,
10
30
50

result table must be

t_2
-------------
0
20
20

first record always zero,but the other record for example second record. 30 --> 30-10 ; third record 50 --> 50-30
Re: sql query problem [message #355955 is a reply to message #355954] Tue, 28 October 2008 13:27 Go to previous messageGo to next message
Littlefoot
Messages: 20901
Registered: June 2005
Location: Croatia, Europe
Senior Member
Account Moderator
Read documentation about the LAG function.
Re: sql query problem [message #355957 is a reply to message #355955] Tue, 28 October 2008 13:43 Go to previous messageGo to next message
emrecaniaz
Messages: 3
Registered: October 2008
Junior Member
thanks but this query must work on oracle and mysql so i cant use this function
Re: sql query problem [message #355959 is a reply to message #355957] Tue, 28 October 2008 13:48 Go to previous messageGo to next message
Michel Cadot
Messages: 64139
Registered: March 2007
Location: Nanterre, France, http://...
Senior Member
Account Moderator
So you should post your question in a mysql forum as all what can be done in mysql can be done in Oracle but the opposite is wrong.

In all cases you must have an order, so this is the first thing you have to define.

Regards
Michel

[Updated on: Tue, 28 October 2008 13:49]

Report message to a moderator

Re: sql query problem [message #355961 is a reply to message #355959] Tue, 28 October 2008 13:56 Go to previous messageGo to next message
emrecaniaz
Messages: 3
Registered: October 2008
Junior Member
i need a answer but i dont want register the other forums
Re: sql query problem [message #355969 is a reply to message #355961] Tue, 28 October 2008 14:52 Go to previous messageGo to next message
Michel Cadot
Messages: 64139
Registered: March 2007
Location: Nanterre, France, http://...
Senior Member
Account Moderator
You have an answer:
Quote:
In all cases you must have an order, so this is the first thing you have to define.

Post it along with a test case: create table and insert statements.

Regards
Michel

[Updated on: Tue, 28 October 2008 14:54]

Report message to a moderator

Re: sql query problem [message #355971 is a reply to message #355969] Tue, 28 October 2008 15:19 Go to previous messageGo to next message
ThomasG
Messages: 3189
Registered: April 2005
Location: Heilbronn, Germany
Senior Member
Quote:

i need a answer but i dont want register the other forums



So..... You get into a bus with the words "I need to fly to Hawaii, but I don't want to get into a plane", too? Very Happy
Re: sql query problem [message #356016 is a reply to message #355961] Wed, 29 October 2008 01:16 Go to previous message
Littlefoot
Messages: 20901
Registered: June 2005
Location: Croatia, Europe
Senior Member
Account Moderator
emrecaniaz wrote on Tue, 28 October 2008 19:56
i need a answer but i dont want register the other forums


A (partially) MySQL-related question along with the above statement would be this month's winner (if there were awards here).
Previous Topic: Performance Issue...
Next Topic: Using variable
Goto Forum:
  


Current Time: Thu Dec 08 18:46:27 CST 2016

Total time taken to generate the page: 0.09392 seconds