使用max函数的SQL查询 [英] sql query using max function

查看:86
本文介绍了使用max函数的SQL查询的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

select MAX(count) from (select COUNT(*) from Foodbazaar_tbl  where Foodbazaar_tbl.Category_name Like'XYZ%' UNION ALL  select COUNT(*)  from Weightmanagement_tbl where Weightmanagement_tbl.Category_name Like'XYZ%')



当我执行查询时收到错误:'')''附近的语法不正确。



感谢's

Sravya。


when i execute the query am getting Error:Incorrect syntax near '')''.

Thank''s
Sravya.

推荐答案

你需要命名t在括号内创建的临时表格,例如

You need to "name" the temporary table that is being created within the brackets e.g.
select MAX(count)
from
(
    select COUNT(*)
    from Foodbazaar_tbl
    where Foodbazaar_tbl.Category_name Like'XYZ%'

    UNION ALL

    select COUNT(*)
    from Weightmanagement_tbl
    where Weightmanagement_tbl.Category_name Like'XYZ%'
) as temp



我还建议为临时列命名计数,例如选择COUNT(*)作为rcount


这篇关于使用max函数的SQL查询的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆