如题,例:
序列号   值     日期
001      100    2010/7/1
001      100    2010/7/1
002      100    2010/7/1
根据指定的日期值:2010/7/1
対序列号字段进行求值,001只留一个,求和结果应为:2
这个sql语句应该怎么写,能不能把它嵌套在另一个select里?
我这样写:
SELECT t1.cd1 as A1,t1.cd2 as B1,
        sum(select distinct no from t2) as no
from   t1
left join t2 as t2
on t1.A_no=t2.no
where t2.date='2010/7/1'
 
上表为 t2