SQL 选择失败。3706:语法错误:预期在“,”和请求结束之间
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/33881680/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
SELECT Failed. 3706: Syntax error: expected something between ',' and the end of the request
提问by Dkratzer
Getting Error code '3706'. Looks to be something with a comma in my syntax. Tried to strip the code down as much as possible, yet still getting the error. My SQL is below. Using Teradata as well. Any ideas?
获取错误代码“3706”。看起来在我的语法中带有逗号。试图尽可能地剥离代码,但仍然出现错误。我的 SQL 在下面。也使用 Teradata。有任何想法吗?
Thanks for the help.
谢谢您的帮助。
SELECT work_order_number,
sub_type_level_2,
reporting_region,
[create_date]+7-Weekday([create_date],7) AS WE,
create_date
FROM rpt_v_dm_all_work_orders
GROUP BY work_order_number, sub_type_level_2, reporting_region,
create_date
HAVING (((reporting_region)='Pacific') AND ((create_date) Between Date()-16 And Date()-3));
回答by Kamil Gosciminski
I've formatted your code and removed some redundant parentheses.
我已经格式化了您的代码并删除了一些多余的括号。
I've added max()
on a column you don't have in your GROUP BY
statement as well.
我已经添加max()
了一个你在你的GROUP BY
陈述中没有的专栏。
Please try this:
请试试这个:
SELECT
work_order_number,
sub_type_level_2,
reporting_region,
max([create_date]+7-Weekday([create_date],7)) AS WE,
create_date
FROM
rpt_v_dm_all_work_orders
GROUP BY work_order_number, sub_type_level_2, reporting_region, create_date
HAVING
(
reporting_region = 'Pacific'
AND create_date Between Date()-16 And Date()-3
);