我正在尝试在我们的票务网站上汇总用户的实时视图。
目前,我在网站上有 2 个会话(Session col)。我当前的查询返回以下内容:
EVENTID EVENT Session SessionOpened SessionLength NumberofTix
1619 BB King 11 2013-01-28 09:34:16.300 -2 2
1622 BB King 12 2013-01-28 09:36:55.073 0 1
1622 BB King 12 2013-01-28 09:36:55.077 0 3
但是,它应该如下所示:
EVENTID EVENT Session SessionOpened SessionLength NumberofTix
1619 BB King 11 2013-01-28 09:34:16.300 -2 2
1622 BB King 12 2013-01-28 09:36:55.073 0 4
为什么第 12 次会议返回 2 行——1 行有 1 张票,1 行有 3 张票?
查询:
SELECT distinct set_eSRO_Event as EventID, shName as EventName, setSRO_UID as SRO_SessionID, setDateTime as SessionStarted,
DATEDIFF(mi, getDate(), setDateTime) as SessionTimer, Count(*) AS NumberofTickets FROM SessionTickets
INNER JOIN Shows on shCode = setShowCode
WHERE setStatus = 0
GROUP BY setsro_UID, shName, set_eSRO_Event, setDateTime