sql语句的问题 - MS-SQL Server / 基础类
有2个表啊:
表名:yh
用户编码 用户名称
001 a
002 b
003 c
表名:ys
用户编码 本期指数 抄表时间
001 11 2009-01-13
001 2 2009-02-26
002 3 2009-01-13
002 1 2009-02-26
两个表的通过用户编码 来关联:
希望得到下面的结构
用户编码 用户名称 本期指数
001 a 2
002 b 1
003 c 0
SQL code:
SELECT A.用户编码,用户名称, 本期指数 =COUNT(*)
from YH A,YS B
WHERE A.用户编码=B.用户编码
GROUP BY A.用户编码,用户名称
SQL code:
select
yh.*,
isnull(ys.本期指数,0) as 本期指数
from
yh
left join
ys
on yh.用户编码 =ys.用户编码
and not exists(select 1 from ys t where t.用户编码=ys.用户编码 and t.抄表时间>ys.抄表时间)
select c.*,t.抄表时间
from yb c,(
select *
from ys a
where not exists (select 1
from ys b
where a.用户编码=b.用户编码 and a.超标时间<b.抄表时
相关问答:
执行的顺序:
1)文件浏览框(选择文件使用)
选择好文件后
点击一个导入按钮的时候 ,把上面上传框里的csv文件以一个ID为文件名,上传到**/**文件夹下
2)读取这个文件夹下的csv的文件,转换成sql
3 ......
type Exception report
message
description The server encountered an internal error () that prevented it from fulfilling this request.
exception
org.apache.jas ......
各位大侠救命啊 !!
刚装了SQL2000 sp3
想用JSP连接数据库但是出现问题了
我用的是JDK6.0+tomcat5.0+SQL2000 SP3+JDBC sp3
它显示的是
javax.servlet.ServletException: [Microsoft][SQLServer 2000 Driver fo ......
直接启动 点了等一会儿就没反应了 去服务那里启动会出现如下提示
出现“本地计算机上的MSSQLSERVER服务启动后又停止了。一些服务自动停止,如果它们没有什么可做的
然后还有什么什么不存在
......
我一个项目,有个插入操作,具体是这样的:
我有进货信息表。在出货时选择相应的进货信息,输入数量,选择部门后,点保存按钮,由于网络延时,点一下没有反映,于是用户就又点一下,导致一次插入了两条记录:
例:
......