我系统中有三张表分别是POSD,PROMH,PROMD,我想在sql2005的数据库里面对这三张表进行联合查询,但是这三张表中的saledate,promstart,promend三个日期字段当时都是使用的字符串定义的,因此无法从日期上来进行限制。我原来的语句如下:
select b.promno,a.saledate,sum(a.qnt*a.price) from posd a,promh b,promd c
where a.saledate>=b.promstart
and a.saledate<=b.promend
and b.promno=c.promno
group by b.promno,a.saledate