| 1 |
create table t2 (a smallint(6) not null, b int(10) not null, name varchar(20), primary key(a,b), key(name)) engine=InnoDB; |
| 2 |
insert into t2 values (8355,3,"sanja"),(8355,4,"wlad"),(8366,5, "lawrin"),(8366,6,"markusjm"); |
| 3 |
select count(distinct name) from t2 where a=8366 and b>=5 and b<=5; |
| 4 |
count(distinct name) |
| 5 |
1 |
| 6 |
select count(distinct name) from t2 where a=8366 and b=5; |
| 7 |
count(distinct name) |
| 8 |
1 |
| 9 |
select count(distinct name) from t2 where a=8366 and b between 5 and 5.5; |
| 10 |
count(distinct name) |
| 11 |
1 |
| 12 |
select sum(distinct a) from t2 where a=8366 and b>=5 and b<=5; |
| 13 |
sum(distinct a) |
| 14 |
8366 |
| 15 |
select sum(distinct a) from t2 where a=8366 and b=5; |
| 16 |
sum(distinct a) |
| 17 |
8366 |
| 18 |
select sum(distinct a) from t2 where a=8366 and b between 5 and 5.5; |
| 19 |
sum(distinct a) |
| 20 |
8366 |
| 21 |
drop table t2; |