SQL计算问题 - MS-SQL Server / 疑难问题
SELECT a.线别, a.工单, a.型号, a.工单量, a.计划小时产量, a.联板数量, a.锡膏批号, a.目标良率, a.站位, a.完成时间, a.计划用时, a.机器用时,
计算用时 = isnull(cast(datediff(SS, a.完成时间, b.完成时间) AS int), ''), 差异 = isnull(cast(datediff(SS, a.完成时间, b.完成时间) AS int), '') - a.计划用时,
a.抛料数量, a.id
from (SELECT idd = row_number() OVER (ORDER BY 完成时间), *
from SmtResultReport1) a LEFT JOIN
(SELECT idd = row_number() OVER (ORDER BY 完成时间), *
from SmtResultReport1) b ON a.idd = b.idd - 1
语句如上:
上面的结果已经是我要的结果的了,结果假设如下:
列1 列2 列3
a 2010-05-08 15:30:30.100 1
b 2010-05-08 15:31:30.100 1
c 2010-05-08 15:32:30.100 1
d 2010-05-08 15:33:30.100 0
我想改成如下结果:
列1 列2 列3
a 2010-05-08 15:30:30.100 0
b 2010-05-08 15:31:30.100 1
c 2010-05-08 15:32:30.100 1
d 2010-05-08 15:33:30.100 1
请问上面的语句应该怎么改?谢谢!
SQL code:
SELECT a.线别, a.工单, a.型号, a.
相关问答:
type Exception report
message
description The server encountered an internal error () that prevented it from fulfilling this request.
exception
org.apache.jas ......
现在有两张表:文章主表A(articleId,articleTitle),文章评论表B(commentId,articleId,commentTitle)
现在我想实现这样的功能:列出文章列表,其中每篇文章标题下面列出此文章的前2个文章评论,请问sql语句怎么写啊 ......
请教高手:
以下是数据库中的三条记录,英文为字段名称
id planname TaskBeginTime Status
329 2010年03 ......
求个vb中的sql语句的写法,次sql语句的用法是分页程序
我写的如下:其中A是用来接收每页显示的记录的条数,B是用来接收显示的当前的页面.
sqltext="select top A * from log where id not in(select top ( ......
查询学生平均成绩及其名次
SELECT 1+(SELECT COUNT( distinct 平均成绩)
from (SELECT S#,AVG(score) AS 平均成绩
from SC&n ......