SQL 查询语句问题!错误提示看不懂呀。求解!
下面是SQL语句:select*from(selectrtrim(ltrim(data0006.work_order_number))as'作业单号',rtrim(ltr...
下面是SQL语句:
select * from
(select
rtrim(ltrim(data0006.work_order_number)) as '作业单号',
rtrim(ltrim(data0050.CUSTOMER_PART_NUMBER)) as '厂内编码',
rtrim(ltrim(data0034.DEPT_CODE)) as '工序代码',
rtrim(ltrim(data0034.dept_name)) as '工序名称',
convert(int,isnull(data0048.QTY_PROD/report_data0050_information.panel,0)) '产出PNL',
isnull(convert(decimal(18,4),data0048.QTY_PROD),0)*((convert(decimal(18,4),report_data0050_information.panel_liYongLv)/100*(report_data0050_information.panelL*report_data0050_information.panelK))/report_data0050_information.panel)/1000000 '产出净面积'
from
data0056 with(nolock)
left join data0006 with (nolock) on data0056.wo_ptr=data0006.rkey
left join data0050 with (nolock) on data0006.CUST_PART_PTR=data0050.rkey
left join data0034 with (nolock) on data0034.rkey=data0056.D_G_W_PTR
join data0048 with (nolock) on data0056.rkey=data0048.TPUT_PTR
left join data0057 with (nolock) on data0057.TRAN_PTR=data0048.rkey
left join data0005 with (nolock) on data0005.rkey=data0057.EMPL_PTR
cross apply dbo.report_data0050_information(data0050.rkey)
left join
(
select DATA48_PTR,EMPL_PTR,TRANS_DATETIME from data0553 with (nolock) where trans_type=2
)
data0553_1 on data0553_1.DATA48_PTR = data0048.RKEY
left join DATA0005 data0005_1 with (nolock) on data0005_1.RKEY=data0553_1.EMPL_PTR
where
(DATA0006.WORK_ORDER_NUMBER like '%' + '090359-52' + '%')
)
错误提示:
消息 102,级别 15,状态 1,第 28 行
')' 附近有语法错误。
双击提示是在最后1行的那个括号。 减去的话 就少了一个括号呀,反正怎么改都是这个错误。
这个括号的意思是想在这个结果的基础上添加 union all 进行统计的。
这个错误怎么改才可以。
刚来这个公司没多久,数据库表明看的楞了半天!表介意! 展开
select * from
(select
rtrim(ltrim(data0006.work_order_number)) as '作业单号',
rtrim(ltrim(data0050.CUSTOMER_PART_NUMBER)) as '厂内编码',
rtrim(ltrim(data0034.DEPT_CODE)) as '工序代码',
rtrim(ltrim(data0034.dept_name)) as '工序名称',
convert(int,isnull(data0048.QTY_PROD/report_data0050_information.panel,0)) '产出PNL',
isnull(convert(decimal(18,4),data0048.QTY_PROD),0)*((convert(decimal(18,4),report_data0050_information.panel_liYongLv)/100*(report_data0050_information.panelL*report_data0050_information.panelK))/report_data0050_information.panel)/1000000 '产出净面积'
from
data0056 with(nolock)
left join data0006 with (nolock) on data0056.wo_ptr=data0006.rkey
left join data0050 with (nolock) on data0006.CUST_PART_PTR=data0050.rkey
left join data0034 with (nolock) on data0034.rkey=data0056.D_G_W_PTR
join data0048 with (nolock) on data0056.rkey=data0048.TPUT_PTR
left join data0057 with (nolock) on data0057.TRAN_PTR=data0048.rkey
left join data0005 with (nolock) on data0005.rkey=data0057.EMPL_PTR
cross apply dbo.report_data0050_information(data0050.rkey)
left join
(
select DATA48_PTR,EMPL_PTR,TRANS_DATETIME from data0553 with (nolock) where trans_type=2
)
data0553_1 on data0553_1.DATA48_PTR = data0048.RKEY
left join DATA0005 data0005_1 with (nolock) on data0005_1.RKEY=data0553_1.EMPL_PTR
where
(DATA0006.WORK_ORDER_NUMBER like '%' + '090359-52' + '%')
)
错误提示:
消息 102,级别 15,状态 1,第 28 行
')' 附近有语法错误。
双击提示是在最后1行的那个括号。 减去的话 就少了一个括号呀,反正怎么改都是这个错误。
这个括号的意思是想在这个结果的基础上添加 union all 进行统计的。
这个错误怎么改才可以。
刚来这个公司没多久,数据库表明看的楞了半天!表介意! 展开
1个回答
展开全部
left join
(
select DATA48_PTR,EMPL_PTR,TRANS_DATETIME from data0553 with (nolock) where trans_type=2
) AS 这里需要添加别名
(
select DATA48_PTR,EMPL_PTR,TRANS_DATETIME from data0553 with (nolock) where trans_type=2
) AS 这里需要添加别名
更多追问追答
追问
left join
(
select DATA48_PTR,EMPL_PTR,TRANS_DATETIME from data0553 with (nolock) where trans_type=2
)
data0553_1 on data0553_1.DATA48_PTR = data0048.RKEY
别名在下行呢 有别名的
追答
最后一行 ) AS 这里需要添加别名
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询