_覓 | 覦覈襦 | 豕蠏手 | 殊螳 | 譯殊碁 |
FrontPage › Function伎郁屋
|
|
MSSQL Server 2000覿 襯 蟆 . 螳讌 一危壱朱 襴願 蠍磯, 企 一危磯 襴危 . 豌 覦企. 襯 伎覃 麹 焔レ 手 螻, 觜讀 襦讌 伎 朱襦 蟯襴朱 ク. 襷 蟆曙 螳 螳螳 襷 ろ 蟆曙磯 . れ 蟆曙磯ゼ 危エ覲伎.
CREATE FUNCTION fn_SumUnitPrice (@ProductID int) RETURNS NUMERIC AS BEGIN DECLARE @result NUMERIC SELECT @result = SUM(UnitPrice) FROM SalesOrderDetail WHERE ProductID = @ProductID RETURN(@result) END GO SELECT ProductID, dbo.fn_SumUnitPrice(ProductID) FROM( SELECT ProductID FROM SalesOrderDetail GROUP BY ProductID) A WHERE dbo.fn_SumUnitPrice(ProductID) > 10000 fn_SumUnitPrice SalesOrderDetail 企 ProductID襯 ル ProductID覲襦 螻襯 蟲 企. 襯 伎伎 れ る 貎朱Μ 蟆郁骸 讀, ProductID UnitPrice 螻螳 10000 伎 蟆襷 蟆郁骸讌 襷る朱 蟆企. 蠏碁 ろ 企慨覃 蟾蟾 覓伎企. SalesOrderDetail 企 ProductID 譬襯 266螳讌企. 覲企 螳 覯 覈朱襦 266 * 2 覯 襷 螳 . 覓朱 蠏碁 ProductID覲襦 Sum() 覃 . 蠏碁 蟆曙磯ゼ 襷り鍵 企襦 貎朱Μ螳 伎る 螳 襦 . 蠏碁る InLine View襯 伎覃 企蟾? 螳 企慨.
SELECT ProductID, SumUnitPrice FROM ( SELECT ProductID, dbo.fn_SumUnitPrice(ProductID) 'SumUnitPrice' FROM( SELECT ProductID FROM SalesOrderDetail GROUP BY ProductID) A ) B WHERE SumUnitPrice > 10000 旧 . 伎 InLine View襯 朱 ろ螻 SumUnitPrice > 10000 dbo.fn_SumUnitPrice(ProductID) > 10000 朱 觜蟲襯 蠍 覓語企. 襯 覲企 .
SELECT TOP 1 ProductID, SumUnitPrice FROM ( SELECT ProductID, dbo.fn_SumUnitPrice(ProductID) 'SumUnitPrice' FROM( SELECT ProductID FROM SalesOrderDetail GROUP BY ProductID) A ) B WHERE SumUnitPrice > 10000 Filter襦 fn_SumUnitPrice(ProductID) > 10000 . 蠏碁覩襦 企 蟆曙磯 碁殊 觀磯ゼ 朱 譬 蟆郁骸襯 螳語 . WHERE 譟郁唄 k 蟆覲企 l 蟆 蟆郁骸 觜襴 . 蠏碁覩襦 企 蟆曙磯 朱 WHERE 譟郁唄 襯 螻 企 伎 .
SELECT ProductID, dbo.fn_SumUnitPrice(ProductID) 'SumUnitPrice' INTO #SumUnitPrice FROM( SELECT ProductID FROM SalesOrderDetail GROUP BY ProductID) A SELECT ProductID, SumUnitPrice FROM #SumUnitPrice WHERE SumUnitPrice > 10000 DROP TABLE #SumUnitPrice SLECT ~ FROM 襷覃 讌 襷蠍磯ゼ 蟠ロ. 覓朱 襯 覃 覈 覲蟆曙 所 焔レ 譬蟆 讌襷 襯 覈 覃 豌 觜 螳語 . 襯 伎 焔 襯 伎 郁屋 ′語 襦襯 谿瑚蠍 覦.
鏤
|
碁レ 蟆 螻 襷 蟆 詞朱る 螻褐 . (蟯危) |