我有两张桌子:
Ticket
表:
sale_date, center_id, ticket_id
Center
表:
center name, center_id
我需要有关如何使结果看起来像附加图像的帮助:
我试过运行脚本,重新安排并没有给我带来好运。
declare @salefrom datetime
declare @saleto datetime
select @salefrom = '2015-10-01 00:00:00'
select @saleto = '2015-10-31 23:59:59'
SELECT
DATEPART(MM, t.Sale_Date) [MONTH],
DATEPART(DD, t.Sale_Date) [DAY],
c.Center_name [centers],
COUNT(ticket_id) AS [Tickets]
FROM
Ticket t
INNER JOIN
Center c ON c.center_id = t.center_id
WHERE
t.Sale_Date BETWEEN @salefrom AND @saleto
AND t.status <> 1
GROUP BY
DATEPART(MM, t.Sale_Date), DATEPART(DD, t.Sale_Date), c.Center_name
ORDER BY
DATEPART(MM, t.Sale_Date), DATEPART(DD, t.Sale_Date), c.Center_name
谢谢, lemi