0

我目前是 sql 查询语言的初学者,目前正在努力使以下查询正常工作:

USE test;
GO
SELECT deal_type, price_type, 
    COUNT(deal_type) OVER(PARTITION BY deal_type) AS "Count1"
,COUNT(price_type) OVER(PARTITION BY deal_type) AS "Count2"  
FROM deal_price
WHERE deal_type = "rmbs", "Abs"
GO

我目前收到错误消息(“msg 156”)

所需的输出如下所示:

--deal_type, price_type, count_1
--rmbs, talk, 23
--rmbs, cvr, 40
--abs, talk, 40 

任何帮助将不胜感激。谢谢你。

4

1 回答 1

0

使用In-clause

USE test;
GO
SELECT deal_type, price_type, 
COUNT(deal_type) OVER(PARTITION BY deal_type) AS 'Count1',
COUNT(price_type) OVER(PARTITION BY deal_type) AS 'Count2'  
FROM deal_price
WHERE deal_type in ('rmbs', 'Abs')
GO
于 2013-01-16T16:00:12.167 回答