MSSQL中如何选择一行中最小的时间?
一张表,字段分为id,time1,time2,time3,time4,time5
请问我应该如何选择ID为1的那条记录中time时间最小的值呢?
UP!
[code=SQL][/code]select min(t) from
(select time1 as t from t1 where id=1 union all
select time2 as t from t1 where id=1 union all
select time3 as t from t1 where id=1 union all
select time4 as t from t1 where id=1 union all
select time5 as t from t1 where id=1 ) as tb
[code=SQL][/code] select min(t) from
(select time1 as t from t1 where id=1 union all
select time2 as t from t1 where id=1 union all
select time3 as t from t1 where id=1 union all
select time4 as t from t1 where id=1 union all
select time5 as t from t1 where id=1 ) as tb
用动态连接一下字符串
晕。。。这么多的SQL语句啊。。那执行起来所花的时候是不是很多啊。。。
SQL code:
----------------------------------------------------------------
-- Author :SQL77(只为思齐老)
-- Date :2010-01-26 19:29:35
-- Version:
-- Microsoft SQL Server 2000 - 8.00.194 (Intel X86)
-- Aug 6 2000 00:57:48
-- Copyright (c) 1988-2000 Microsoft Corporation
-- Desktop Engine on Windows NT 5.1 (Build 2600: Service Pack 3)
--
----------------------------------------------------------------
--> 测试数据:#TB
if object_id('TB') is not null drop table TB
go
cr
相关问答:
一个总站.三个子站共四个ASP开发的站点;数据库是MSSQL2000;四个站各有自己的数据库(四个站点的库结构都是一样的.),各有自己的信息添加后台,四个站是独立的.四个站都在同一个服务器中.
现在需要现实:
一.如何让总站 ......
现有一个ASP+mssql的网站,被挂马了,将里面一个表中的ntext字段挂马挂马,“<script src=http://木马地址></script>”,的方式是,不断地修改该字段的值,直接加在最后的,时间长了,可以看到该字段中有 ......
有一个数据库里只有2W条数据不到,却有500M那么大,怎么回事啊?是ACCESS的数据库。后来我把ACCESS导入到MSSQL中,也占用了500M左右的空间,如果压缩数据库呢?请高手指点
压缩数据库?能做到么...
期待高人指点 我 ......
安装过程时没出现错误提示。 一直到结束,则说MSSQL 没安装成功
Summary.txt 内容如下:
Overall summary:
Final result: ......
表的结构如下:
表1:tb_big
字段:falseID值:1,2
字段:bigtype 值:A,B(与falseID的值的位置一一对应,即1对应A,2对应B)
表2:tb_small
字段:falseID(与tb_big的falseID关联的 ......