Help with query on sparse timeseries data

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Massimiliano Campagnoli

    #1

    Help with query on sparse timeseries data

    Good morning,

    I have a table like (Date, Hour, Value) where Date can be any date,
    Hour is always between 6 (6am) to 22 (10pm) and Value is an integer.

    E.G.

    Date Hour Value
    23/2/2002 6 2
    23/2/2002 7 3
    23/2/2002 8 2
    23/2/2002 12 5

    24/2/2002 8 9
    24/2/2002 9 1
    24/2/2002 10 2
    24/2/2002 11 2
    .....

    please note that some hour can be missing inside the same date, for
    instance hour 9,10,11,13,14,1 5,16,17,18,19,2 0,21,22 are missing for
    date 23/2/2002 and hour 6 and 7 are missing for date 24/2/2002

    I need a query to list for every date and hour the corresponding value
    but including also any missing hour (for missing hour the default for
    Value is 0).

    E.G.

    Date Hour Value
    23/2/2002 6 2
    23/2/2002 7 3
    23/2/2002 8 2
    23/2/2002 9 0
    23/2/2002 10 0
    23/2/2002 11 0
    23/2/2002 12 5
    23/2/2002 13 0
    23/2/2002 14 0
    23/2/2002 15 0
    23/2/2002 16 0
    23/2/2002 17 0
    23/2/2002 18 0
    23/2/2002 19 0
    23/2/2002 20 0
    23/2/2002 21 0
    23/2/2002 22 0
    24/2/2002 6 0
    24/2/2002 7 0
    24/2/2002 8 9
    24/2/2002 9 1
    24/2/2002 10 2
    24/2/2002 11 2
    .....


    How can I achieve this ?

    Thanks.





Working...