sql server - Can the WHERE conditions affect specific columns? -



sql server - Can the WHERE conditions affect specific columns? -

i creating procedure , have encountered next problem. (i using microsoft sql server 2008)

i have 1 table contained info spread on month (let's 1st 30th). each day of month contains same amount of info (so each day of month has same number of rows in table). have 1 column info of pertaining start date , 1 info end date (i don't want info in between shown).

i have tried using bring together this:

create procedure afficherconsompools @start date, @end date select datecollecte, pool, capacityinkb, freecapacityinkb, endusedcapacityinkb = capacityinkb - freecapacityinkb vsp_pool datecollecte = @end bring together select startusedcapacityinkb = capacityinkb - freecapacityinkb vsp_pool datecollecte = @start

but didn't worked (i don't think can have bring together statement after where).

i tried using case don't think it's need here. i'm looking way apply status in different columns (instead of of them).

thanks help!

you seek this:

create procedure afficherconsompools ( @start date, @end date) begin select [pool], max(case when datecollected = @start capacityinkb - freecapacityinkb else 0 end) startusedcapacityinkb, max(case when datecollected = @end capacityinkb - freecapacityinkb else 0 end) endusedcapacityinkb vsp_pool datecollected in (@end, @start) grouping [pool]; end;

sql-server sql-server-2008 where

Comments

Popular posts from this blog

php - Android app custom user registration and login with cookie using facebook sdk -

django - Access session in user model .save() -

php - .htaccess Multiple Rewrite Rules / Prioritizing -