消息 4145,级别 15,在“)”附近预期条件的上下文中指定的非布尔类型的表达式。错误
Msg 4145, Level 15, An expression of non-boolean type specified in a context where a condition is expected, near ')'. error
我试图显示别名 [totalmonthly]
的最大值,我试图输入 {SUM(([Price]-[CostToMake])* MonthlySales)}
但仍然没有显示。我在这里做错了什么?
SELECT Name,
SUM(([Price]-[CostToMake])* MonthlySales) AS TotalMonthly
FROM SalesTable
GROUP BY Name
HAVING MAX(TotalMonthly)
我收到错误消息:
Msg 4145, Level 15,
An expression of non-boolean type specified in a context where a condition is expected, near ')'
使用TOP (1)
和ORDER BY
:
SELECT TOP (1) Name,
SUM(([Price]-[CostToMake])* MonthlySales) AS TotalMonthly
FROM SalesTable
GROUP BY Name
ORDER BY TotalMonthly DESC;
我假设您的查询产生了错误,而不是错误的结果。
我试图显示别名 [totalmonthly]
的最大值,我试图输入 {SUM(([Price]-[CostToMake])* MonthlySales)}
但仍然没有显示。我在这里做错了什么?
SELECT Name,
SUM(([Price]-[CostToMake])* MonthlySales) AS TotalMonthly
FROM SalesTable
GROUP BY Name
HAVING MAX(TotalMonthly)
我收到错误消息:
Msg 4145, Level 15,
An expression of non-boolean type specified in a context where a condition is expected, near ')'
使用TOP (1)
和ORDER BY
:
SELECT TOP (1) Name,
SUM(([Price]-[CostToMake])* MonthlySales) AS TotalMonthly
FROM SalesTable
GROUP BY Name
ORDER BY TotalMonthly DESC;
我假设您的查询产生了错误,而不是错误的结果。