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
相关问答:
有意者请联系yushan-33@hotmail.com / 18821146311
Microsoft SQL Administrator
Job Description:
A detail oriented Microsoft SQL Administratorwith excellent problem solving, analyti ......
如何将MSSQL数据库转换为MYSQL
在网上找了很多 说的很乱 请问有高手可以教下吗 谢谢了
没有什么好办法。两者之间还是有些差异的。
数据类型,存储过程语法。
如果只是表和记录,则可以安装一个MYS ......
请问MSSQL是否支持离线文件的发布和订阅?比如生成同步文件后再复制到要同步的服务器进行同步?
没有这么先进吧
引用
请问MSSQL是否支持离线文件的发布和订阅?比如生成同步文件后再复制到要同步的服务器进行 ......
表的结构如下:
表1:tb_big
字段:falseID值:1,2
字段:bigtype 值:A,B(与falseID的值的位置一一对应,即1对应A,2对应B)
表2:tb_small
字段:falseID(与tb_big的falseID关联的 ......