像错误的语法附近得到错误* [英] Getting the error like incorrect syntax near *

查看:55
本文介绍了像错误的语法附近得到错误*的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

 选择 Th.groupY,
Th.CDPY,
Bh.fold
< span class =code-keyword> as count(*)
来自 dbo.tblTraceHeaders as Th
left outer 加入 dbo.tblBinaryHeaders Bh on Th.fileID = Bh.fileID 其中 Th.fileID 1 5 3
Th.groupY,Th.CDPY,Bh.fold

count(*) > 1 Th.fileID in (< span class =code-digit> 1 , 5 3

解决方案

Bh.fold因为使用关键字而无法使用Count(*)。



您可以通过添加方括号或单引号将其转换为隐式列标题:



 < span class =code-keyword>选择 Th.groupY,
Th.CDPY,
Bh.fold as [count (*)]
来自 dbo.tblTraceHeaders as Th
left outer join dbo.tblBinaryHeaders as Bh on Th.fileID = Bh.fileID 其中 Th.fileID 1 5 3
< span class =code-keyword>按 Th.groupY,Th.CDPY,Bh.fold

count( *)> 1 Th.fileID in (< span class =code-digit> 1 , 5 3





这不是你想要的吗?



也许你想用这个数(*)而不是将列命名为?



 选择 Th .groupY,
Th.CDPY,
Bh.fold, - 缺少逗号
count(*) as [count(*)] - 添加计数并将其命名为计数(*)
来自 dbo.tblTraceHeaders as Th
left outer 加入 dbo.tblBina ryHeaders as Bh on Th.fileID = Bh.fileID 其中 Th.fileID in 1 5 3
通过 Th.groupY,Th.CDPY,Bh.fold

count(*)> 1 Th.fileID in (< span class =code-digit> 1 , 5 3





让我知道这些都不是你需要的^ _ ^


第一个:您在汇总名称或列名称之后将设置为 - > count(*)as mycount



:输入你想要的列名计算功能而不是* - > 计数(COLUMNNAME)

select Th.groupY,
Th.CDPY,
Bh.fold
as count(*)
from dbo.tblTraceHeaders as Th
left outer join dbo.tblBinaryHeaders as Bh on Th.fileID=Bh.fileID where Th.fileID in (1,5,3)
Group By Th.groupY,Th.CDPY,Bh.fold
having
count(*)> 1 and Th.fileID in (1,5,3)

解决方案

Bh.fold as Count(*) can't work because of the use of the keyword.

You can turn this into an implicit column header by either adding square braces or single quotes:

select Th.groupY,
    Th.CDPY,
    Bh.fold as [count(*)]
from dbo.tblTraceHeaders as Th
    left outer join dbo.tblBinaryHeaders as Bh on Th.fileID=Bh.fileID where Th.fileID in (1,5,3)
Group By Th.groupY,Th.CDPY,Bh.fold
having
    count(*)> 1 and Th.fileID in (1,5,3)



Is this not what you intended?

maybe you want to use the count(*) instead of naming the column such?

select Th.groupY,
    Th.CDPY,
    Bh.fold, --missing comma
    count(*) as [count(*)] -- add a count and name it count(*)
from dbo.tblTraceHeaders as Th
    left outer join dbo.tblBinaryHeaders as Bh on Th.fileID=Bh.fileID where Th.fileID in (1,5,3)
Group By Th.groupY,Th.CDPY,Bh.fold
having
    count(*)> 1 and Th.fileID in (1,5,3)



let me know if neither of these are what you need ^_^


First : you put as after the aggregate or column name -> count(*) as mycount

Second : put the column name you want to count in the function and not * -> count(columnname)


这篇关于像错误的语法附近得到错误*的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆