您的位置:首页 > Web前端 > Node.js

sql server查询NodeId字段中距离某一时间最近的所有数据

2017-07-27 16:43 411 查看
没别的啥,就是想写个sql语句

sql语句:

 select * from

    (select nodeId,max(UpdateTime)as UpdateTime

        from JT_InspectNode_Update

        where PathID in (1, 2)

        and deltag = 0

        and UpdateTime <=

            (select MAX(UpdateTime)as UpdateTime

                from JT_InspectNode_Update

                where UpdateTime <= '2017-07-24 11:51:30')

        group by nodeId) as t1,

        (select * from JT_InspectNode_Update where PathID in (1,2) and deltag = 0)as t2

        where t1.NodeId = t2.NodeId and t1.UpdateTime = t2.UpdateTime order by t2.NodeId
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: 
相关文章推荐