328
328
drop table t1,t2,t3;
329
create table t1 (a int not null, b int not null, t time);
330
insert into t1 values (1,1,"00:06:15"),(1,2,"00:06:15"),(1,2,"00:30:15"),(1,3,"00:06:15"),(1,3,"00:30:15");
331
select a,sec_to_time(sum(time_to_sec(t))) from t1 group by a,b;
332
a sec_to_time(sum(time_to_sec(t)))
336
select distinct a,sec_to_time(sum(time_to_sec(t))) from t1 group by a,b;
337
a sec_to_time(sum(time_to_sec(t)))
340
create table t2 (a int not null primary key, b int);
341
insert into t2 values (1,1),(2,2),(3,3);
342
select t1.a,sec_to_time(sum(time_to_sec(t))) from t1 left join t2 on (t1.b=t2.a) group by t1.a,t2.b;
343
a sec_to_time(sum(time_to_sec(t)))
347
select distinct t1.a,sec_to_time(sum(time_to_sec(t))) from t1 left join t2 on (t1.b=t2.a) group by t1.a,t2.b;
348
a sec_to_time(sum(time_to_sec(t)))
352
329
create table t1 (a int not null,b char(5), c text);
353
330
insert into t1 (a) values (1),(2),(3),(4),(1),(2),(3),(4);
354
331
select distinct a from t1 group by b,a having a > 2 order by a desc;