我正在尝试创建一个(sqlite)查询,该查询将执行GROUP BY,但不会将值为’unknown’的任何内容进行分组.例如,我有表:
id | name | parent_id | school_id | 1 | john | 1 | 1 | 2 | john | 1 | 1 | 3 | john | 1 | 1 | 4 | nick | 2 | 2 | 5 | nick | 2 | 2 | 6 | nick | 3 | 3 | 7 | bob | 4 | 4 | 8 | unknown | 5 | 5 | 9 | unknown | 5 | 5 | 10| unknown | 5 | 5 |
通过’GROUP BY name,parent_id,school_id’的正确查询,我需要返回以下行:
id | name | parent_id | school_id | 1 | john | 1 | 1 | 3 | nick | 2 | 2 | 4 | nick | 3 | 3 | 5 | bob | 4 | 4 | 6 | unknown | 5 | 5 | 7 | unknown | 5 | 5 | 8 | unknown | 5 | 5 |
任何帮助将不胜感激.谢谢!