SQL Server group query combined with date fuzzy query

Source: Internet
Author: User

Group query:

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

Date format format:

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

Conversions between dates and strings:

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

Fuzzy Query for Date:

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°c) 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°c) 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°c) like convert (varchar, GETDATE (), 23)
ORDER by A.tm DESC

SQL Server group query combined with date fuzzy query

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.