Forum Replies Created

Viewing 15 posts - 31 through 45 (of 73 total)

  • RE: Using CASE in a WHERE clause

    GSquared (12/3/2010)


    select *

    from dbo.MyTable

    where @Parameter = 'A'

    or ParentTradeID is not null and @Parameter = 'O'

    or ParentTradeID is null and @Parameter = 'R';

    Wouldn't that do it?

    Of course, thanks. My brain...

  • RE: Using CASE in a WHERE clause

    Sachin Nandanwar (12/3/2010)


    Cant you just use IF blocks ?

    Yes, I could use IF blocks... 😉

  • RE: Averaging data streaks

    Awesome works great thanks

  • RE: Averaging data streaks

    Here's some more sample data

    DELETE [accountperformance]

    INSERT INTO [accountperformance] ([tradeId],[pctAccountRisked],[profit],[tradeDateTime])VALUES(1,3.00,110.000000,'Jan 19 2010 11:00:00:000AM')

    INSERT INTO [accountperformance] ([tradeId],[pctAccountRisked],[profit],[tradeDateTime])VALUES(2,1.80,104.000000,'Jan 28 2010 3:00:00:000PM')

    INSERT INTO [accountperformance] ([tradeId],[pctAccountRisked],[profit],[tradeDateTime])VALUES(3,3.00,463.000000,'Feb 3 2010 7:00:00:000PM')

    INSERT INTO [accountperformance] ([tradeId],[pctAccountRisked],[profit],[tradeDateTime])VALUES(4,0.94,-50.000000,'Feb...

  • RE: Averaging data streaks

    Thanks it doesn't give me the correct results for dates that are the same. Is there a tweak needed to do that?

  • RE: Please help with a query

    WayneS (11/2/2010)


    What you supplied has a purchase (IE) with price of 1.359400.

    First sale (MX) of 1.364100.

    Second sale (XXX) of 1.359700

    so:

    (1.359700 - 1.359400) + (1.364100 - 1.359400) = +0.005000

    Perhaps I have...

  • RE: Please help with a query

    Sorry, here you go 😀

    INSERT INTO [orders] ([orderId],[tradeId],[units],[side],[price],[spread],[strategyId],[signalTypeId],[brokerId],[orderTypeId],[orderDateTime])VALUES(12,4,2,'S',1.359400,1.00,3,'IE',1,'SM','Feb 15 2010 7:00:00:000AM')

    INSERT INTO [orders] ([orderId],[tradeId],[units],[side],[price],[spread],[strategyId],[signalTypeId],[brokerId],[orderTypeId],[orderDateTime])VALUES(14,4,1,'B',1.364100,1.00,3,'MX',1,'BM','Feb 16 2010 7:00:00:000AM')

    INSERT INTO [orders] ([orderId],[tradeId],[units],[side],[price],[spread],[strategyId],[signalTypeId],[brokerId],[orderTypeId],[orderDateTime])VALUES(13,4,1,'B',1.359700,1.00,3,'XXX',1,'BM','Feb 16 2010 7:00:00:000PM')

  • RE: Please help with a query

    Profit should be the sale price - purchase price. Have a look at tradeId 4.

    Buy 1 unit at 1.3641

    Buy 1 unit at 1.3597

    Sell 2 units at 1.3594

    The profit should be...

  • RE: Please help with a query

    Chris Morris-439714 (11/2/2010)


    I think your profit expression is incorrect:

    profit = sum(p.Price - s.Price)

    it should be selling price minus purchase price.

    Chris that is not the case because all the other values...

  • RE: Please help with a query

    Hi Guys,

    I've just added some more sample data and realised that the values of the profit column are wrong. here's some extra sample data to show the wrong values:

    INSERT INTO...

  • RE: Financial modelling query

    Well Chris that was pretty impressive without an instance of SQL Server to test on. Works great, and thanks very much! 😎

  • RE: Financial modelling query

    🙂 I hope your manflu is being kind to you. I now get:

    Msg 207, Level 16, State 1, Line 18

    Invalid column name 'rn'.

  • RE: Financial modelling query

    Thanks I did that and I now get:

    Msg 207, Level 16, State 1, Line 5

    Invalid column name 'accountPerformance'.

    :unsure:

  • RE: Financial modelling query

    Hi Chris, thanks for you reply. It doesn't seem to work, I get this error:

    Msg 137, Level 15, State 2, Line 18

    Must declare the scalar variable "@nannyRisk".

  • RE: Memory Allocation For An Active/Active Cluster.

    Yes the max memory SQL Server can take will be limited to the value you have specified, in your case 4 GB. Bear in mind though that the cache will...

Viewing 15 posts - 31 through 45 (of 73 total)