你能看一下这段代码吗?我收到此错误,我不确定是什么导致它:
')'附近的语法不正确.
select *
from
(select distinct
sar90.code, sar90.state, sar90.county,
sabet.code, sabet.state, sabet.county
from
[dbo].[sarshomari_90] as sar90,
[dbo].[Fixed] as sabet
where
sar90.county = sabet.county
and sar90.state = sabet.state
and sar90.state = N'kerman')
Run Code Online (Sandbox Code Playgroud)
您需要为子查询添加别名.但是,您不需要使用子查询.你可以SELECT DISTINCT直接使用.另外,请避免使用旧式JOIN语法并使用显式JOIN声明.
但是,如果要使用子查询,则列必须具有唯一的名称.通过添加唯一别名来完成此操作.
select *
from(
select distinct
sar90.code as code1,
sar90.state as state1,
sar90.county as country1,
sabet.code as code2,
sabet.state as state2,
sabet.county as country2
from [dbo].[sarshomari_90] as sar90
inner join [dbo].[Fixed] as sabet
on sar90.county = sabet.county
and sar90.state = sabet.state
where
sar90.state = N'kerman'
)t
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
1332 次 |
| 最近记录: |