以這種方式查詢我的結果數據。根據列選擇不同的行
Id Size
123 1
123 1
123 2
123 2
134 1
134 1
134 2
我想要的結果讓我計數消除重複的大小像
Id Size
123 1
123 2
134 1
134 2
上方是連接兩個表的結果。問題是我不能在這種情況下使用不同的。
這裏是表如何
Table1:
Id Created ... .. .. ..
123 date1 ....
134 date2 ....
Table2:
Id Size
123 1
123 2
134 1
134 2
我有我的查詢,從表1基於CreatedDate選擇,它這樣
select count(*)
from table1
join table2
on table1.id = table2.id
where table1.creates between '' and ''.
你如何得到不同尺寸。
如果我使用select count(distinct table2.size),它只對所有行返回1和2。
是的它應該工作。更準確地說, SELECT DISTINCT ID,Size FROM table1,table2 WHERE table1.Id = table2.Id AND'table1.creates'和'' – SNathan