我有一张这样的桌子:
Locid Paydate DelDate vtid
5 2013-05-07 18:36:50.000 2013-05-07 18:58:32.000 7
5 2013-05-07 18:36:50.000 2013-05-07 18:58:32.000 8
6 2013-05-07 18:36:50.000 2013-05-07 18:58:32.000 7
6 2013-05-07 18:36:50.000 2013-05-07 18:58:32.000 8
7 2013-05-07 18:36:50.000 2013-05-07 18:58:32.000 7
我有一个这样的存储过程:
ALTER PROCEDURE [dbo].[performance] @locid INTEGER=NULL
AS
BEGIN
SET NOCOUNT ON;
SELECT l.LocName,
v.Vtype,
SUM(DATEDIFF(MI, t.Paydate, t.DelDate)) AS TotalDiff,
CONVERT(DECIMAL(10, 1), AVG(CONVERT(NUMERIC(18, 2), DATEDIFF(MI, t.Paydate, t.DelDate)))) AS Average
FROM Transaction_tbl t
LEFT JOIN VType_tbl v
ON t.vtid = v.vtid
LEFT JOIN Location_tbl l
ON t.Locid = l.Locid
WHERE t.Locid = @locid
GROUP BY v.Vtype,
l.LocName
END
,在这一次我只能通过一个 locid,有时我需要在一个数据集中放 2 个 locid。所以我怎么能自动通过两个locid。