select count(*) from (select count(*) as temp from logs group by computer_id )lala
select count(*) from (select count(*) as temp from logs group by computer_id )lala ----------這個語句好象沒有意義啊。永遠都是1。
select count(*) from (select count(*) as temp from ( select 1 as computer_id,1 as data union all select 1,2 union all select 2,2 union all select 3,2 union all select 4,2 ) as t group by computer_id )lala--- 4
等同于 求 包括null的不同computer_id的个数与 select count(distinct computer_id) as temp from logs 不同
哦,看少了一部分,沒注意後面有個group by。 :)
select count(*) from (select count(*) as temp from logs group by computer_id )lala------------ 其實這個語句就等同於Select count(Distinct computer_id) from logs
鱼,不同的 select count(*) from (select count(*) as temp from ( select 1 as computer_id,1 as data union all select 1,2 union all select 2,2 union all select null,2 union all select 4,2 ) as t group by computer_id )lala------ 4select count(Distinct computer_id) from ( select 1 as computer_id,1 as data union all select 1,2 union all select 2,2 union all select null,2 union all select 4,2 ) as t------ 3
----------這個語句好象沒有意義啊。永遠都是1。
select 1 as computer_id,1 as data
union all select 1,2
union all select 2,2
union all select 3,2
union all select 4,2
) as t
group by computer_id )lala---
4
select count(distinct computer_id) as temp from logs
不同
其實這個語句就等同於Select count(Distinct computer_id) from logs
select count(*) from (select count(*) as temp from (
select 1 as computer_id,1 as data
union all select 1,2
union all select 2,2
union all select null,2
union all select 4,2
) as t
group by computer_id )lala------
4select count(Distinct computer_id) from (
select 1 as computer_id,1 as data
union all select 1,2
union all select 2,2
union all select null,2
union all select 4,2
) as t------
3