sql server - Shifting position of sql query results -



sql server - Shifting position of sql query results -

i know question seems bit confusing. have query homecoming next result :

is there way shift results can have : null values replaced values below ? room service midi has null value, rest shifted. there way replace that.

my query :

select pc.code, pc.description, case when g.description 'nourriture' , pc.description 'petit dejeuner' coalesce(sum(ta.price),0) when g.description 'nourriture' , pc.description 'banquet' coalesce(sum(ta.price),0) when g.description 'nourriture' , pc.description 'casablanca cafe midi' coalesce(sum(ta.price),0) when g.description 'nourriture' , pc.description 'casablanca cafe matin' coalesce(sum(ta.price),0) when g.description 'nourriture' , pc.description 'casablanca cafe soir' coalesce(sum(ta.price),0) when g.description 'nourriture' , pc.description 'casablanca cafe bar' coalesce(sum(ta.price),0) when g.description 'nourriture' , pc.description 'room service nuit' coalesce(sum(ta.price),0) when g.description 'nourriture' , pc.description 'room service midi' coalesce(sum(ta.price),0) when g.description 'nourriture' , pc.description 'room service soir' coalesce(sum(ta.price),0) when g.description 'nourriture' , pc.description 'room service pdj' coalesce(sum(ta.price),0) when g.description 'nourriture' , pc.description 'xo lounge/midi' coalesce(sum(ta.price),0) when g.description 'nourriture' , pc.description 'banquet lunch' coalesce(sum(ta.price),0) when g.description 'nourriture' , pc.description 'banquet dinner' coalesce(sum(ta.price),0) when g.description 'nourriture' , pc.description 'tabac' coalesce(sum(ta.price),0) when g.description 'nourriture' , pc.description 'xo lounge/soir' coalesce(sum(ta.price),0) when g.description 'nourriture' , pc.description 'terasse bleue' coalesce(sum(ta.price),0) when g.description 'nourriture' , pc.description 'spa' coalesce(sum(ta.price),0) when g.description 'nourriture' , pc.description 'seven' coalesce(sum(ta.price),0) when g.description 'nourriture' , pc.description 'mini bar' coalesce(sum(ta.price),0) when g.description 'nourriture' , pc.description 'chez dada' coalesce(sum(ta.price),0) end sumpricefood, case when g.description 'boisson' , pc.description 'petit dejeuner' sum(ta.price) when g.description 'boisson' , pc.description 'banquet' sum(ta.price) when g.description 'boisson' , pc.description 'casablanca cafe midi' sum(ta.price) when g.description 'boisson' , pc.description 'casablanca cafe matin' sum(ta.price) when g.description 'boisson' , pc.description 'casablanca cafe soir' sum(ta.price) when g.description 'boisson' , pc.description 'casablanca cafe bar' sum(ta.price) when g.description 'boisson' , pc.description 'room service nuit' sum(ta.price) when g.description 'boisson' , pc.description 'room service midi' sum(ta.price) when g.description 'boisson' , pc.description 'room service soir' sum(ta.price) when g.description 'boisson' , pc.description 'room service pdj' sum(ta.price) when g.description 'boisson' , pc.description 'xo lounge/midi' sum(ta.price) when g.description 'boisson' , pc.description 'banquet lunch' sum(ta.price) when g.description 'boisson' , pc.description 'banquet dinner' sum(ta.price) when g.description 'boisson' , pc.description 'tabac' sum(ta.price) when g.description 'boisson' , pc.description 'xo lounge/soir' sum(ta.price) when g.description 'boisson' , pc.description 'terasse bleue' sum(ta.price) when g.description 'boisson' , pc.description 'spa' sum(ta.price) when g.description 'boisson' , pc.description 'seven' sum(ta.price) when g.description 'boisson' , pc.description 'mini bar' sum(ta.price) when g.description 'boisson' , pc.description 'chez dada' sum(ta.price) end sumpriceboisson trans_articles ta, transactions t, profit_centers pc, article_causals ac, groups g, articles t.id = ta.transaction_id , pc.id = t.profit_center_id , ta.causal_id = ac.id , g.id = a.group_a_id , a.id = ta.article_id , ac.causal_type = 1 , ac.code in(103) grouping pc.code, pc.description, g.description

thank reading

try following;

select code ,description ,sum(sumpricefood) sumpricefood ,sum(sumpriceboisson) sumpriceboisson grouping code ,description

to shift results based on code , description need group results together.

sql-server select case

Comments

Popular posts from this blog

formatting - SAS SQL Datepart function returning odd values -

c++ - Apple Mach-O Linker Error(Duplicate Symbols For Architecture armv7) -

php - Yii 2: Unable to find a class into the extension 'yii2-admin' -