此查询出了什么问题?我不断收到错误消息
语法不正确)
查询
SELECT
COUNT(*) QUOTECOUNT
FROM
(SELECT DISTINCT
FIRSTNAME, LASTNAME, DATEOFBIRTH, ZIPCODE
FROM
DBO.RATING_INFO
WHERE
STATE = 'Texas'
AND LOB = 'PersonalAuto'
AND SOURCELASTMODIFIED BETWEEN '2018-05-02 00:00:00' AND '2018-07-03 00:00:00'
AND REQUESTEDBYAPPLICATION = 'MR'
AND EXTERNALPOLICYSUBSOURCE = 'ezlynx');
答案 0 :(得分:2)
您只需要子查询别名,但我还给count加上了一个别名,并将State
放在方括号中是一种很好的措施。在dbms上应该没关系,但是我使用了SQL Server。
SELECT COUNT(*) as QUOTECOUNT
FROM (
SELECT DISTINCT FIRSTNAME, LASTNAME, DATEOFBIRTH, ZIPCODE
FROM DBO.RATING_INFO
WHERE [STATE] = 'Texas' and LOB = 'PersonalAuto'
and SOURCELASTMODIFIED BETWEEN '2018-05-02 00:00:00' AND '2018-07-03 00:00:00'
and REQUESTEDBYAPPLICATION = 'MR'
and EXTERNALPOLICYSUBSOURCE = 'ezlynx'
) c
;
答案 1 :(得分:1)
这里是不使用子查询的替代方法。由于您需要计数不同的值,因此可以轻松地使用分组依据。添加一些空白使其清晰易读,看起来可能像这样。
var value = 'Hello, world!'
var template = document.getElementById('template');
// Magic to convert DOM element to template string `<div id="template">${value}</div>`
console.log(element)
>>> <div id="template">Hello, world!</div>