Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Dao.count时groupBy条件没有生效 #1107

Closed
wendal opened this issue Aug 1, 2016 · 2 comments
Closed

Dao.count时groupBy条件没有生效 #1107

wendal opened this issue Aug 1, 2016 · 2 comments
Assignees
Labels
Milestone

Comments

@wendal
Copy link
Member

wendal commented Aug 1, 2016

    @Test
    public void test_groupby() throws MalformedURLException {
        Cnd cnd = Cnd.where("id", ">", 1);
        cnd.groupBy("name");
        cnd.asc("name");
        //System.out.println(cnd);
        Dao dao = ioc.get(Dao.class);
        dao.query(User.class, cnd); // 生效
        dao.count(User.class, cnd); // 不生效
    }
@wendal wendal added the Dao label Aug 1, 2016
@wendal wendal added this to the 1.r.58 milestone Aug 1, 2016
@wendal wendal self-assigned this Aug 1, 2016
@wendal wendal changed the title Dao.count/funcX时groupBy条件没有生效 Dao.count时groupBy条件没有生效 Aug 1, 2016
wendal added a commit that referenced this issue Aug 1, 2016
Signed-off-by: wendal chen <wendal1985@gmail.com>
@wendal wendal closed this as completed Aug 1, 2016
@dongjiajie
Copy link

NutDao.count(tableName, cnd)得到的是某个查询的分页总数,实际生成的sql应该是select count() from tableName where cnd.... 以此为前提:那么,当cnd =“ 1=1 ” 时,生成的sql为 “select count() from tableName where 1=1 ”这个很容易理解,但是,当cnd = " 1=1 group by name "时,生成的sql就是“select count() from tableName where 1=1 group by name”,这样查询出来的结果是不对的,假如表中有10个不一样的name,count出来就是1,事实用户想要的结果可能是"select count() from (select count(*) from tableName where 1=1 group by name)" (注1),那么我想请问一下,当sql是group by时,我想要注1这样的结果,需要调用哪个方法呢?

@wendal
Copy link
Member Author

wendal commented Aug 14, 2019

用法问题请到nutz.cn发帖

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants