这sql代码执行出现以下问题是什么原因?

邢柏 2018-06-22 02:53:22
[SQL]with abx as
(
select icustay_id
, suspected_infection_time
, specimen, positiveculture
, antibiotic_name
, antibiotic_time
, ROW_NUMBER() OVER
(
PARTITION BY icustay_id
ORDER BY suspected_infection_time
) as rn
from abx_micro_poe
)
select
ie.icustay_id
, antibiotic_name
, antibiotic_time
, suspected_infection_time
, specimen, positiveculture
from icustays ie
left join abx
on ie.icustay_id = abx.icustay_id
and abx.rn = 1
order by ie.icustay_id;

[Err] 错误: 操作符不存在: integer = character varying
LINE 23: on ie.icustay_id = abx.icustay_id
^
HINT: 没有匹配指定名称和参数类型的操作符. 您也许需要增加明确的类型转换.
...全文
166 5 打赏 收藏 转发到动态 举报
写回复
用AI写文章
5 条回复
切换为时间正序
请发表友善的回复…
发表回复
邢柏 2018-06-22
  • 打赏
  • 举报
回复
应用cast(ie.icustay_id as varchar(100))转换后已正确执行,谢谢!
邢柏 2018-06-22
  • 打赏
  • 举报
回复
postgresql9.6,navicat112_premium_cs_x86.exe
zjcxc 2018-06-22
  • 打赏
  • 举报
回复
cast(ie.icustay_id as varchar(100))
在 sql server 中,应该是会自动隐式转换的,楼主用的什么版本?
邢柏 2018-06-22
  • 打赏
  • 举报
回复
请问如何显式转换?谢谢!
shinger126 2018-06-22
  • 打赏
  • 举报
回复
abx_micro_poe和icustays表的icustay_id字段类型不一致,需要显式转换一下

22,209

社区成员

发帖
与我相关
我的任务
社区描述
MS-SQL Server 疑难问题
社区管理员
  • 疑难问题社区
  • 尘觉
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧