sql server - MAX - MIN for each day in SQL -


i using sql server. fetching information various tables, , able that.

in table have sampletime column every 30 minutes, , value column. want write query difference (max-min) each day, suggestions how can that?

for example:

signal name     sampletime                  value spazio-percorso 2014-03-06 15:01:50.3170000 219345   spazio-percorso 2014-03-06 15:31:50.3260000 219384   spazio-percorso 2014-03-06 16:01:50.3380000 219388   spazio-percorso 2014-03-06 16:31:50.3460000 219388   spazio-percorso 2014-03-06 17:01:50.3590000 219400   spazio-percorso 2014-03-06 17:31:50.3690000 219434   spazio-percorso 2014-03-06 18:01:50.3760000 219471 

in example rows same day, want have 1 row each day , in value column want have max-min of day

try this

select [signal name], cast(sampletime date) sampledate, max(value)-min(value) diff_value table1 group cast(sampletime date),[signal name] 

Comments

Popular posts from this blog

Android layout hidden on keyboard show -

google app engine - 403 Forbidden POST - Flask WTForms -

c - Why would PK11_GenerateRandom() return an error -8023? -