繁体   English   中英

从表中选择最大计数并更新另一列

[英]Select max of count from a table and update another column

在此处输入图片说明

在此处输入图片说明

我需要从col1_class列的Count中找到最大值,并使用我尝试此代码的值更新table2列“ lbl1”,但出现错误:

update testClassLable
set lbl1 = (
    select max(maxVal)
    from (
        select count (col1_class) as maxVal
        from tbl_test_all
        group by col1_class
    )x
)

你能帮忙吗?

*更新*

我编辑了上面的代码,现在开始工作,但返回:

0行受到影响!

尝试这个

update testClassLable
set lbl1 = (
    select max(countVal)
    from (
        select count(col1_class) as countVal
        from tbl_test_all
        group by col1_class
    ) x
)

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM