Home » SQL & PL/SQL » SQL & PL/SQL » Need Query, but cant test it... (Oracle)
Need Query, but cant test it... [message #569957] Sat, 03 November 2012 14:06 Go to next message
Messages: 1
Registered: November 2012
Junior Member
Hi everyone, I really hope you can help me on this one...

I have no access to oracle (I'm getting on a plane at the moment), but I need a query for a database, but obviously can't test it or get my head around it without it in front of me.

I need a query which displays all the shareholders who sold shares they don't own from a table in which all share amounts are written as positive numbers, they are associated with a trade type field where 1=buy and 2=sell.

Therefore I need the query to check the transaction times of all previous trades and return the trades where the sum of the share amounts for the previous trades for a shareholder on a particular share is a negative number.

I know I need to put a call to make the share amounts positive or negative before they are summed:

shareid, transactiontime, shareholderid
CALL (transactiontype,
2, 0-shareamount,
1, shareamount,

and also check back on the transaction times for the shares share amounts for shareholders:

a select on the final info needed from trades here, then...

(Sum(share amount IN (the above call select)
Trades T2
T.tradeID = T2.TradeID
T.transactiontime < t2.transactiontime) < 0

Sorry for the mistakes, bad formatting and lack of info/schema, but if someone could put this together into a working (or nearly working!) Query, I'd really, really appreciate it because I'm still relatively new to SQL.

Thanks everyone!

Thanks in advance
Re: Need Query, but cant test it... [message #569959 is a reply to message #569957] Sat, 03 November 2012 14:22 Go to previous messageGo to next message
Michel Cadot
Messages: 65155
Registered: March 2007
Location: Nanterre, France, http://...
Senior Member
Account Moderator
Welcome to the forum.

How could we know if our query is working (or nearly working or simply syntaxically working) with nothing to work on?
With any SQL or PL/SQL question, please, Post a working Test case: create table and insert statements along with the result you want with these data then we will be able work with your table and data. Explain with words and sentences the rules that lead to this result.

Before, Please read OraFAQ Forum Guide and How to use [code] tags and make your code easier to read.
Make sure that lines of code do not exceed 80 characters when you format.
Indent the code, use code tags and align the columns in result.
Use the "Preview Message" button to verify.
Also always post your Oracle version, with 4 decimals.

Re: Need Query, but cant test it... [message #569962 is a reply to message #569959] Sat, 03 November 2012 14:25 Go to previous message
Messages: 25581
Registered: January 2009
Location: SoCal
Senior Member
I hope you enjoyed your plane ride.
Previous Topic: PL/SQL cursor to procedure error.
Next Topic: missing parenthesis error
Goto Forum:

Current Time: Wed Aug 23 22:12:56 CDT 2017

Total time taken to generate the page: 0.01255 seconds