34,590
社区成员
发帖
与我相关
我的任务
分享
--> 数据库版本:
--> Microsoft SQL Server 2008 (RTM) - 10.0.1600.22
--> 测试数据:[TB]
IF EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[TB]')
AND type in (N'U'))
DROP TABLE [TB]
GO
---->建表
create table [TB]([code] varchar(6),[digest] numeric(7,1),[qty] numeric(7,1),[fund] numeric(7,2),[date] numeric(9,1),[time] numeric(9,1))
insert [TB]
select '000039',220000.0,800.0,-4708.88,20100701.0,10101176.0 union all
select '000002',220000.0,3600.0,-24412.58,20100701.0,10021171.0 union all
select '000024',220000.0,300.0,-4467.84,20100701.0,10021173.0 union all
select '000027',220000.0,300.0,-2865.54,20100701.0,10021175.0 union all
select '000039',220000.0,400.0,-4708.88,20100701.0,10021176.0 union all
select '159903',220038.0,300000.0,0.0,20100701.0,10021672.0 union all
select '000002',220000.0,3600.0,-24412.58,20100701.0,09021278.0 union all
select '000002',220000.0,7300.0,-24412.58,20100701.0,11021171.0
GO
select a.*
from [TB] a where [time] = (select top 1 [time] from [TB] where code = a.code) order by a.code
--> 查询结果
SELECT *
FROM [TB]
--> 删除表格
--DROP TABLE [TB]