sql management linq (pivoting)


i'm relocating db mysql (used odbc) ms sql i wish "translate" sql queries linq. someone assistance me (it should sum assign buttress each plcae organisation outcome months):



select
sum(case location="location1" following assign else 0 end) location1,
sum(case location="location2" following assign else 0 end) location2,
sum(case location="location3" following assign else 0 end) location3,
makedate(year(ordertime),dayofyear(ordertime)) date sales
group year(ordertime),month(ordertime)
order ordertime desc


?



output should feeling this:



location1 | location2 | location3 | date


edit:



i tryed linq illustration here:





var query = context.log_sales
.groupby(c => c.ordertime)
.select(g => new
{
date = g.key,
location1 = g.where(c => c.location == "location1").sum(c => c.charge) ?? 0,
location2 = g.where(c => c.location == "location2").sum(c => c.charge) ?? 0
}).tolist();


and roughly i need. there should organization year too i don't know this.



Comments

Popular posts from this blog

list macos calm editors formula editors

how hibernate @any-related annotations?

why does floated <input> control floated component slip over too distant right ie7, nonetheless firefox?