博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
sqlserver获取系统时间
阅读量:6034 次
发布时间:2019-06-20

本文共 1620 字,大约阅读时间需要 5 分钟。

1. getdate()

SELECT t1.SKCD as reservoirid,

t1.SKNM as reservoirname,
t1.RSVRTP as rsvrtp,
t6.FSLTDZ as xunxianshuiwei,
t1.LGTD AS jingdu,
t1.LTTD AS weidu,
t3.DYP AS precipitation,
t3.TM AS rainTm,
t4.RZ as waterlevel,
t4.TM as waterTm,
t4.RZ - t6.FSLTDZ as chaoxunxianshuiwei,
img.CHID AS chid,
DATEPART(yyyy,img.TM) as yearN ,
img.TM as imgTm,
t1.STLC as adress
FROM SK_BASIC_B t1
LEFT JOIN
ST_PPTN_R_V t3 ON t1.STCD = t3.STCD
LEFT JOIN
RS_RSVR_R_V t4 ON t1.STCD = t4.STCD
LEFT JOIN
sk_fcch_b t6 ON t1.SKCD = t6.SKCD
LEFT JOIN
(select a.CHID,a.TM,b.SKCD from SK_RTIMAGE_R a, SK_RTIMGCFG_B b
where a.CHID = b.CHID and ENABLED = 1
<if test="skcd != null and skcd != '' ">
and b.SKCD = #{skcd}
</if>
and ORDERINDEX = 1
and TM = (select top 1 TM from SK_RTIMAGE_R where CHID = a.CHID
<if test="dateEnd != null and dateEnd != '' ">
and #{dateEnd}>=TM
</if>
order by TM desc
)
)img ON img.SKCD=t1.SKCD
WHERE 1 = 1
<if test="skcd != null and skcd !=''">
AND t1.SKCD = #{skcd}
</if>
<if test="cityid != null and cityid != -1">
AND t1.SKCD LIKE '4205%'
</if>
<if test="reservoirname != null and reservoirname != '' ">
AND t1.SKNM LIKE '%${reservoirname}%'
</if>
order by (t4.RZ - t6.FSLTDZ) desc

2.求最大时间的数据

select a.CHID,a.TM,b.SKCD

from SK_RTIMAGE_R a, SK_RTIMGCFG_B b

where a.CHID = b.CHID and ENABLED = 1
<if test="skcd != null and skcd != '' ">
and b.SKCD = #{skcd}
</if>
and ORDERINDEX = 1
and TM = (select top 1 TM from SK_RTIMAGE_R where CHID = a.CHID
      <if test="dateEnd != null and dateEnd != '' ">
      and #{dateEnd}>=TM
      </if>
    order by TM desc  )

 

转载于:https://www.cnblogs.com/zb347954263/p/6734268.html

你可能感兴趣的文章
什么是注入点
查看>>
python 常见脚本
查看>>
MYSQL安装图解2
查看>>
UVA 11212 Editing a Book
查看>>
****** 二 ******、软设笔记【数据结构】-KMP算法、树、二叉树
查看>>
hadoop生态搭建(3节点)-15.Nginx_Keepalived_Tomcat配置
查看>>
数据库基础积累
查看>>
jQuery超链接提示,提示跟随鼠标动
查看>>
javascript 日期函数
查看>>
spring学习之bean scope
查看>>
大家一起和snailren学java-(五)访问控制权限
查看>>
大家一起和snailren学java-(13)字符串
查看>>
BigDecimal的用法详解(保留两位小数,四舍五入,数字格式化,科学计数法转数字,数字里的逗号处理)...
查看>>
TJOI2018Party
查看>>
系统登录界面(收集)
查看>>
[翻译]WP7 QuickStart-第八篇-屏幕方向
查看>>
第四次作业——个人作业——软件案例分析
查看>>
Tomcat学习总结(3)——Tomcat优化详细教程
查看>>
Linux学习总结(22)——CentOS7.2安装Nginx
查看>>
Java基础学习总结(5)——多态
查看>>