Can someone help convert this query to SQL. I need this in linQ and I dont have write perms to get alternative for Storedprocedure. So linQ is the only way for me now to get it used with Silverlight
SELECT ISNULL(COUNT(BGID),0)AS BGCOUNT,CASE SOURCE.PRIORITY
WHEN 1 THEN 'P1'
WHEN 2 THEN 'P2'
WHEN 3 THEN 'P3'
END AS PRIORITY FROM
(SELECT DISTINCT PRIORITY AS PRIORITY FROM BGS WHERE PRIORITY IS NOT NULL)AS SOURCE
LEFT OUTER JOIN BGS ON BGS.PRIORITY = SOURCE.PRIORITY AND
TREEPATH NOT LIKE '%Prod%' AND TREEPATH LIKE '%TMS%' AND
TREEPATH NOT LIKE 'BG\structure\Aut\TMS%' AND STATUS = 'ACTIVE' AND
(ASSIGNEDTO = 'cato14' OR ASSIGNEDTO IN
('useratadi','userajsudh','useramanna','useritnaga'))
GROUP BY SOURCE.PRIORITY
ORDER BY SOURCE.PRIORITY