码迷,mamicode.com
首页 > 数据库 > 详细

sql server 分组查询结合日期模糊查询

时间:2017-12-08 20:45:56      阅读:242      评论:0      收藏:0      [点我收藏+]

标签:data   hive   www   模糊   detail   结合   desc   target   har   

分组查询:

https://www.cnblogs.com/netserver/p/4518995.html

日期格式化格式:

http://blog.csdn.net/qq_16769857/article/details/52289627

日期和字符串之间的转换:

https://www.cnblogs.com/windphoenix/archive/2013/04/26/3044784.html

日期的模糊查询:

https://zhidao.baidu.com/question/507141127.html

 

SELECT a.*
FROM WATERQuarter a INNER JOIN
(SELECT datacd, MAX(tm) tm
FROM waterQuarter
GROUP BY datacd) b ON a.DATACD = b.datacd AND a.TM = b.tm 
AND  CONVERT(varchar, a.TM, 23) LIKE ‘2017-11-24%‘

ORDER BY a.TM DESC

 

SELECT a.*
FROM WATERQuarter a INNER JOIN
(SELECT datacd, MAX(tm) tm
FROM waterQuarter
GROUP BY datacd) b ON a.DATACD = b.datacd AND a.TM = b.tm 
WHERE  CONVERT(varchar, a.TM, 23) LIKE ‘2017-11-24%‘
ORDER BY a.TM DESC

 

SELECT a.*
FROM WATERQuarter a INNER JOIN
(SELECT datacd, MAX(tm) tm
FROM waterQuarter
GROUP BY datacd) b ON a.DATACD = b.datacd AND a.TM = b.tm AND 
CONVERT(varchar, a.TM, 23) LIKE CONVERT(varchar, GETDATE(), 23)
ORDER BY a.TM DESC

sql server 分组查询结合日期模糊查询

标签:data   hive   www   模糊   detail   结合   desc   target   har   

原文地址:http://www.cnblogs.com/jeryM/p/8006822.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!