我要将EXISTS子查询的结果应用到上层的select中
如
select id,totalproduct/(usetime) from detail a
where exists(select name,id,datediff(getdate(),creatdate) as usetime from product where id=a.id)
当然这是错误的 usetime不识别
有木有什么方法可以将子查询的这个结果usetime传到外围那个SELECT 中
如
select id,totalproduct/(usetime) from detail a
where exists(select name,id,datediff(getdate(),creatdate) as usetime from product where id=a.id)
当然这是错误的 usetime不识别
有木有什么方法可以将子查询的这个结果usetime传到外围那个SELECT 中
LZ这个只能用子查询或者是连接表的方式处理了。
a.totalproduct/datediff(d,getdate(),p.creatdate)
from detail a
inner join product p on a.id=p.id