Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

The Database Forum


You are currently viewing our The Database Forum as a guest. Please register to participate.
Login



Reply
Need help with constructing a Nested Select query statement
Old 12-27-2009, 09:38 AM Need help with constructing a Nested Select query statement
Novice Talker

Posts: 9
Trades: 0
I am trying to construct a query statement that allows me to retrieve what’s known as “Bullish Divergence” in stock investing signals. It occurs when stock price reaches to a new high level, surpassing a previous price peak, while a certain strength indicator on the same date fails to surpass the strength indicator of the previous peak. This would suggest the stock price is over-valued.

My table currently contains Date, Ticker (name of stock), Price, and RSI (the strength indicator). The goal is to retrieve all the stocks with bullish divergence occurring on 11/24/2009, and I am looking at a 10-day window for peaks.

The logic is to first find all the stocks whose prices have reached new highs on 11/24/2009 within the past 10 days, and if their RSI figures fail to be greater than the RSI figures of the previous peaks, then we have a bullish divergence.

I currently have the following query statement, which returns an error message saying “Subquery returned more than 1 value and cannot be used when subquery follows <, >, >=, <=, =”. Could anyone please help me with this? I would be very thankful as I’ve spent hours trying to get it to work. Thanks!!

SELECT Date, Ticker, Price, RSI
FROM Table
WHERE (Price =
(SELECT MAX(Price) AS Expr1
FROM Table AS t2
WHERE (Table.Ticker = Ticker) AND (Date BETWEEN DATEADD(day, - 10, '11/24/2009') AND '11/24/2009'))) AND (Date = '11/24/2009') AND

(RSI <
(SELECT RSI
FROM Table AS t3
WHERE (Price =
(SELECT MAX(Price) AS Expr1
FROM Table AS t4
WHERE (t3.Ticker = Ticker) AND (Date BETWEEN DATEADD(day,
-10, '11/23/2009') AND '11/23/2009')))))
NobleJms is offline
Reply With Quote
View Public Profile
 
 
Register now for full access!
Old 12-27-2009, 12:24 PM Re: Need help with constructing a Nested Select query statement
kly
Banned

Posts: 2
Trades: 0
so hard, i don't know, hope you settle soon.
kly is offline
Reply With Quote
View Public Profile
 
Reply     « Reply to Need help with constructing a Nested Select query statement
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 0.15771 seconds with 12 queries