SQL question

Discussion in 'Automated Trading' started by nitro, Oct 9, 2010.

  1. Piffle

    Piffle

    If I am understanding your problem correctly (and I'm not sure I am), try something like this. This should show all rows where there exist multiple rows for the same date x.

    select mt1.x, mt1.y, mt1.z
    from mytable mt1
    where trunc(mt1.x) in (select trunc(mt2.x)
    from mytable mt2
    group by trunc(mt2.x)
    having count(trunc(mt2.x))>1)

    I am not logged into a database right now, but this is close to what it would be in Oracle, if not exact. The trunc function removes the timestamp from the date in Oracle. If you are not in Oracle, there should be an equivalent function or way to manipulate the date to remove the timestamp.
     
    #21     Oct 12, 2010
  2. EricOblon

    EricOblon

    nice code.thanks for sharing.
     
    #22     Oct 12, 2010