SQL Server 2008数据库时间查询 [英] SQL Server 2008 Database Time Query

查看:605
本文介绍了SQL Server 2008数据库时间查询的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在一个表中有一个类似下面的记录,我的问题是我需要获取????使用数据库查询或C#代码获得的值.请指教吗?

什么是 "???"柱子?上一个输出[减去]当前输入

I have a records like below in a table, my problem is I need to get ??? values from using database query or C# code. Kindly advise?

What is "???" column? Previous Out[minus]Current In

<table>
  Date         In          Out        ???
10/26/2012  16:29:26    16:29:29
10/26/2012  16:31:21    16:31:25    0:01:52
10/26/2012  16:49:40    16:49:48    0:18:15
</table>

推荐答案

1)您需要弄清楚存在的模式.真的很简单.
2)您需要弄清楚如何根据步骤1中找到的模式进行计算.
3)编写sql代码以生成该列的数据.
1) You need to figure out the pattern that exists. It is really quite simple.
2) You need to figure out how to calculate based on the pattern found in step 1.
3) Write sql code to generate that column''s data.


非常容易做到-
1.从SQL获取TOP 2记录

Pretty easy to do-
1. Get TOP 2 records from SQL

SELECT TOP 2 Out,In FROM tbl ORDER BY Out DESC



2.获取第二行的In列和第一行的Out列的值.
3.获得2个值之间的差.



2. Get the values of In column in 2nd row and Out column in 1st row.
3. Get the difference between 2 values.


从表中选择CONVERT(varchar,(Out-in),108)FROM Table
SELECT CONVERT(varchar,(Out - in), 108) FROM Table


这篇关于SQL Server 2008数据库时间查询的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆