Results 1 to 3 of 3

Thread: Re: help please

  1. #1
    Join Date
    May 2004

    Unhappy Unanswered: Re: help please

    Dear all,

    I have 3 column: date, time, stocks name, price

    I have 2 questions:

    1. what is the command (or query languange) to get the
    the first and/or last observations for any given day (i know it can be done in
    aggregate query, in Ms acces but can it be done in SQL server query as well?)?
    e.g. I want to get the first and last price of the day for any particular stocks

    2. how to calculate return with the following formula:
    return=log P(t)-log P(t-1), where P(t) is price at
    time t say 10 am and P(t-1) is price at one period
    previous t say 9 am?



  2. #2
    Join Date
    May 2004
    The min and max functions will tell you the price ranges

    eg select max(pricecolumn) from tablename where date='20040517'

    select min(pricecolumn) from tablename where date='20040517'

    If you want to be more selective look at the date/time setting you are using in your data and tailor the where command to select at that particular time

    eg where date='2003-02-28 10:00:00.000'

    Look at books online for the log function, and use selective where clauses for the times, ie where date='2004-05-17 10:00:00.000'
    Last edited by RichardW; 05-17-04 at 08:56.

  3. #3
    Join Date
    Feb 2004
    select max(pricecolumn) from tablename where date='20040517'
    broup by [stocks name]

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts