drop table if exists t1; create table t1(c1 int primary key, c2 int); insert into t1 values(7,3),(8,3),(1,1),(2,0),(3,1),(4,0),(5,2),(6,2); select c1 as a1,c2 as a2 from t1 group by a2 order by a1; a1 a2 1 1 2 0 5 2 7 3 select c1 as a1,c2 as a2 from t1 group by a1 order by a2; a1 a2 2 0 4 0 1 1 3 1 5 2 6 2 7 3 8 3 select c1 as a1,c2 as a2 from t1 group by a2 order by a2; a1 a2 2 0 1 1 5 2 7 3 select c1 as a1,c2 as a2 from t1 group by a1 order by a1; a1 a2 1 1 2 0 3 1 4 0 5 2 6 2 7 3 8 3 select c1 as a1,c2 as a2 from t1 order by a2; a1 a2 2 0 4 0 1 1 3 1 5 2 6 2 7 3 8 3 select c1 as a1,c2 as a2 from t1 order by a1; a1 a2 1 1 2 0 3 1 4 0 5 2 6 2 7 3 8 3 select c1 as a1,c2 as a2 from t1 group by a2 having a2>0 order by a1; a1 a2 1 1 5 2 7 3 select c1 as a1,c2 as a2 from t1 group by a2 having a2>0 order by a2; a1 a2 1 1 5 2 7 3 select c1 as a1,c2 as a2 from t1 group by a2 having a1>0 order by a1; a1 a2 1 1 2 0 5 2 7 3 select c1 as a1,c2 as a2 from t1 group by a2 having a1>0 order by a2; a1 a2 2 0 1 1 5 2 7 3 select c1+c2 as total from t1 order by total; total 2 2 4 4 7 8 10 11 select c1, c1+c2 as total from t1 group by total order by c1; c1 total 1 2 3 4 5 7 6 8 7 10 8 11 select c1, c1+c2 as total from t1 group by total having c1>2 order by c1 desc; c1 total 8 11 7 10 6 8 5 7 4 4 select c1 as a1, c2 as a2 from t1 where c1>1; a1 a2 2 0 3 1 4 0 5 2 6 2 7 3 8 3 select c1 as a1, c2 as a2 from t1 where c2>1; a1 a2 5 2 6 2 7 3 8 3 select c1,c1+c2 as a1 from t1 where c1+c2>2; c1 a1 3 4 4 4 5 7 6 8 7 10 8 11