Linq inside SQL server ?
Posted on 2012-04-11
Lets say I have a query like this:
SELECT a.ID, a.Description,
[answer] = CASE WHEN a.ID=1 THEN 'Something'
ELSE ( SELECT sum(x.Amount) END
FROM Table1 a
LEFT JOIN Table2 x on x.ID = a.ID
WHERE x.currentYear = 2011
ok my question is...
lets I would like to include a WHERE clause saying where x.period = 10
is it possible to write that clause inside the Case when on the select? do to it like this:
ELSE ( SELECT sum(x.Amount) where x.Period = 10 )... ?
I know i could write the clause after my left join but i need to know if there is a way to do like in vb.net some LINQ?
i hope my question is clear...