我如何用LINQ來模擬Derived Table
?如何模擬衍生表與LINQ到實體
考慮下面的代碼:
SELECT * FROM (SELECT * FROM Mytbl) AS tmp WHERE tmp.ID=1
我如何使用LINQ寫的嗎?
感謝
編輯1:
如何將其轉換爲LINQ?:
select
convert(decimal(10,1), ROUND(A.c2*100,8)),
convert(decimal(10,1), ROUND(A.c3*100,8))
from
(
SELECT
(
SELECT CONVERT(INT, COUNT(ID))
FROM tbl
WHERE (col06 >= @param_Min and col06 <= @param_Max)
)
/
(
SELECT CONVERT(INT, COUNT(ID))
FROM tbl
WHERE (col06 >= 10)
) as c2
(
SELECT CONVERT(INT, COUNT(ID))
FROM tbl
WHERE (col06 >= @param_Min and col06 <= @param_Max)
AND (col03 = 1)
)
/
(
SELECT CONVERT(INT, COUNT(ID))
FROM tbl
WHERE (col06 >= 10) AND (col03 = 1)
) as c3
) AS A
你應該展現真實的例子,當你想使用它,因爲你當前的例子是一樣的' SELECT * FROM MyTbl WHERE ID = 1'這使您的問題得到解決。 – 2012-01-03 10:42:39
是這是一個簡單的例子。我更新我的問題 – Arian 2012-01-03 10:47:15