避免子查询
各位同仁, 我有一个查询如下:
SELECT A.ID, B.ID, (HUGE SUBQUERY) as HS
FROM TABLE_A JOIN TABLE_B ON A.ID = B.ID
WHERE (HUGE SUBQUERY) > 0
我想避免重复子查询。 有没有什么方法可以将我的 WHERE 重写为类似
WHERE HS > 0
Or 我必须将子查询转换为联接?
Fellows,
I have a query as follows:
SELECT A.ID, B.ID, (HUGE SUBQUERY) as HS
FROM TABLE_A JOIN TABLE_B ON A.ID = B.ID
WHERE (HUGE SUBQUERY) > 0
I'd like to avoid repeating the subquery.
Is there any way to rewrite my WHERE as something like
WHERE HS > 0
Or I must turn my subquery into a join?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
查看 With 子句:
OR
Look at With clause :
OR
您可以使用 CTE:
You could use a CTE: