Viewing 15 posts - 1 through 15 (of 20 total)
I want to extend my query to get the Minimum Date and Time with Maximum Date and Time
ID xSymbol MaxDate MaxTime MinDate MinTime
1 MSFT 101 77 ...
July 25, 2012 at 12:05 pm
Karthiart (7/24/2012)
Hi, Something like this..SELECT A.XSYMBOL,A.XCLOSE,A.XDATE AS ILASTDATE,A.XTIME AS ILASTTIME FROM
(SELECT *,
ROW_NUMBER() OVER (PARTITION BY XSYMBOL ORDER BY XDATE DESC, XTIME DESC) [RANK]
FROM STOCKQUOTE)A
WHERE [RANK] = 1
Thanks, That works!...
July 24, 2012 at 2:31 am
J Livingston SQL (7/22/2012)
tobinare (7/22/2012)
J Livingston SQL (7/22/2012)
one idea...not performance testedThank's, I like your solution and I never would have thought of it.
its probably only one of many ways.....only...
July 22, 2012 at 2:09 pm
J Livingston SQL (7/22/2012)
one idea...not performance tested
Thank's, I like your solution and I never would have thought of it.
I added a join of the StockQuote with #TempSymbolList to produce...
July 22, 2012 at 1:06 pm
GilaMonster (7/21/2012)
Please post definitions for the tables involved and some sample data.Also, instead of EXECing the string, print it and post the output.
I found the problem. I need brackets...
July 21, 2012 at 2:50 pm
GilaMonster (7/21/2012)
SELECT @info = STUFF(( SELECT ', ' + 'MAX([' + TempSymbol + ']) As ['+ TempSymbol + ']'FROM #TempSymbolList
FOR XML PATH('')...
July 21, 2012 at 1:36 pm
GilaMonster (7/21/2012)
You'll need to wrap the column names (as you build them up for the pivot) in []
I'm not sure I know what you mean?
July 21, 2012 at 11:23 am
Thanks, clayman and vinus! Both solutions worked with the exception of one maybe not so small point. I did not get the symbols in the header. Is this...
July 20, 2012 at 5:13 am
vinu512 (6/5/2012)
--Static Pivot
Select xDATE, Max(MSFT), MAX(AAPL), MAX(AMD) From
(Select xDATE, [MSFT], [AAPL], [AMD] From
(Select A.* From StockQuote as A
JOIN #TempSymbolList as B ON A.xSymbol = B.TempSymbol)...
June 5, 2012 at 4:20 am
vinu512 (6/5/2012)
--Static Pivot
Select xDATE, [MSFT] As CloseSymbol1, [AAPL] As CloseSymbol2, [AMD] As CloseSymbol3 From
(Select A.* From StockQuote as A
JOIN #TempSymbolList as B ON...
June 5, 2012 at 3:34 am
Evil Kraig F (6/5/2012)
June 5, 2012 at 1:08 am
This will create a table of the stock data, I stripped out everything but the close ( no open,high low)
USE [StockQuoteDB]
-- create the stock Quote Table
CREATE TABLE [dbo].[StockQuote](
[ID] [int] IDENTITY(1,1)...
June 5, 2012 at 12:43 am
dwain.c (5/28/2012)
SELECT t3.SYMBOL, t3.COMPANY
FROM @TABLE1 t1
INNER JOIN @TABLE2 t2 ON t1.SYMBOL = t2.SYMBOL
CROSS APPLY (SELECT SYMBOL, COMPANY FROM @TABLE2 t3 WHERE t2.SECTOR = t3.SECTOR) t3...
May 29, 2012 at 1:01 am
Yes you are correct. I edited the original post.
May 28, 2012 at 11:04 pm
Viewing 15 posts - 1 through 15 (of 20 total)