简体   繁体   English

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

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

在此处输入图片说明

在此处输入图片说明

I need to find the max value base on Count from column col1_class and update table2 column 'lbl1' with the value I tried this code but i gets error: 我需要从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
)

can you help please? 你能帮忙吗?

* UPDATE * *更新*

I edited the code above and its work now but it return : 我编辑了上面的代码,现在开始工作,但返回:

0 row(s) affected ! 0行受到影响!

try this 尝试这个

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