Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 Help with query

Author  Topic 

jcarrallo
Starting Member

35 Posts

Posted - 2014-05-19 : 05:53:21
Hello Team,

Please help me with this query:

The table is as follows:

PVL_Date | PVL_Symbol | Pvl_Daily_Return
01/02/2013 | GOOG| 0,12
02/02/2013 | GOOG| -0,07
03/02/2013 | GOOG| 0,212
01/02/2013 | AAPL| -0,19
02/02/2013 | AAPL| 0,33
03/02/2013 | AAPL| -0,43

And below is a query to get a list of prices for a specific stock by date, and where I accumulate the daily return.

Select Pvl_Date, Pvl_Symbol, SUM(Pvl_Daily_Return) OVER (ORDER BY pvl_date) AS 'Accumulated'
FROM Stock_Prices
WHERE Pvl_Symbol = 'GOOG' and pvl_Date > '31/01/13'
Order by Pvl_Date

And the result of this query is:

PVL_Date | PVL_Symbol | Accumulated
01/02/2013 | GOOG| 0,12
02/02/2013 | GOOG| -0,05
03/02/2013 | GOOG| 0,262


So this is all fine, except that I would need to include a '0' right at the begining of the list. So in other words, I would need the query result to be:

PVL_Date | PVL_Symbol | Accumulated
31/01/2013 | GOOG| 0
01/02/2013 | GOOG| 0,12
02/02/2013 | GOOG| -0,05
03/02/2013 | GOOG| 0,262

Can anyone help with this?
Many thanks in advanced
Jay

kostya1122
Starting Member

15 Posts

Posted - 2014-05-19 : 14:05:54

pvl_Date >= '31/01/13'
Go to Top of Page

jcarrallo
Starting Member

35 Posts

Posted - 2014-05-20 : 14:53:03
Thanks. This will do.
Best,
Jay
Go to Top of Page
   

- Advertisement -