help in sql query plaese. . .

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • sameer18
    New Member
    • Mar 2008
    • 1

    help in sql query plaese. . .

    Table:

    Date/Time PRICE value
    11/3/2008 11:11:01 21 210
    11/3/2008 11:11:02 23 210
    11/3/2008 11:11:03 25 210

    11/3/2008 11:12:01 21 210
    11/3/2008 11:12:02 32 210

    11/3/2008 11:13:02 45 210
    11/3/2008 11:13:05 23 210

    11/3/2008 11:15:30 56 210
    11/3/2008 11:15:35 67 210

    This is my table structure what I want is I want to display the data minute wise
    I.e. I want my o/p like this.


    THIS IS MY FINAL O/P I WANT


    O/P:
    Date/Time open high low close value
    11/3/2008 11:11 21 25 21 25 620
    11/3/2008 11:12 21 32 21 32 420
    11/3/2008 11:13 45 45 23 23 420
    11/3/2008 11:15 56 67 21 67 630

    Here open, high, low, close, volume details are coming from PRICE column. The only thing is compare the all seconds within the minute, and display the values minute wise.
  • deepuv04
    Recognized Expert New Member
    • Nov 2007
    • 227

    #2
    Originally posted by sameer18
    Table:

    Date/Time PRICE value
    11/3/2008 11:11:01 21 210
    11/3/2008 11:11:02 23 210
    11/3/2008 11:11:03 25 210

    11/3/2008 11:12:01 21 210
    11/3/2008 11:12:02 32 210

    11/3/2008 11:13:02 45 210
    11/3/2008 11:13:05 23 210

    11/3/2008 11:15:30 56 210
    11/3/2008 11:15:35 67 210

    This is my table structure what I want is I want to display the data minute wise
    I.e. I want my o/p like this.


    THIS IS MY FINAL O/P I WANT


    O/P:
    Date/Time open high low close value
    11/3/2008 11:11 21 25 21 25 620
    11/3/2008 11:12 21 32 21 32 420
    11/3/2008 11:13 45 45 23 23 420
    11/3/2008 11:15 56 67 21 67 630

    Here open, high, low, close, volume details are coming from PRICE column. The only thing is compare the all seconds within the minute, and display the values minute wise.
    try this

    [code=sql]

    select convert(varchar (30),date,103) + ' ' + convert(varchar (30),date,108),
    min(price) as low,max(price) as high,sum(value) as value
    from Table_name
    group by convert(varchar (30),date,103) + ' ' + convert(varchar (30),date,108)
    [/code]

    Comment

    • deepuv04
      Recognized Expert New Member
      • Nov 2007
      • 227

      #3
      Originally posted by deepuv04
      try this

      [code=sql]

      select convert(varchar (30),date,103) + ' ' + convert(varchar (30),date,108),
      min(price) as low,max(price) as high,sum(value) as value
      from Table_name
      group by convert(varchar (30),date,103) + ' ' + convert(varchar (30),date,108)
      [/code]

      Small change in the above code :
      instead of convert(varchar (30),date,108) use convert(varchar (5),date,108)
      which will give you correct results


      [code=sql]
      select convert(varchar (10),date,103) + ' ' + convert(varchar (5),date,108) ,
      min(price) as low,max(price) as high,sum(value) as price
      from timeval
      group by convert(varchar (10),date,103) + ' ' + convert(varchar (5),date,108)
      [/code]

      Comment

      Working...