以这种方式查询我的结果数据。根据列选择不同的行
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