我系统中有三张表分别是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
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
解决方案 »
- 碰到两个奇怪的问题
- top关键字的用法!
- 问个极菜的问题............
- 有办法查看SQLSERVER2008 死锁历史么?
- 请教一个查询语句
- 初学者问多表外连接问题
- 各位看一下我这个存储过程写的有什么问题啊
- *********好着急!!只8000多条记录查询怎么也会出现超时??*********
- 能否用SQL语句实现将文本文件导成Sql_server的数据库表?
- 用vb做进销存软件,能在互联网上发布,用什么数据库好,access(容量太小)?sql server?或其他?请推荐一种
- 这几条语句是什么意思?limit
- 怎样用JDBC连接SQL Server2005,客户端需要怎么设置啊
Conver(SmallDateTime,colname)
Convert(SmallDateTime,Colname)
from posd a,promh b,promd c
where cast(a.saledate as datetime) between cast(b.promstart as datetime) and cast(b.promend as datetime)
and b.promno=c.promno
group by b.promno,a.saledate