SQL query sorting, self-comparison, start the program

Source: Internet
Author: User

System. Diagnostics. process. Start (@ "D: \ Foxmail \ foxmail.exe ");

Select *
From monthlypolicisemonitor
Where cast ([year] As nvarchar (10) + '-0' + Cast ([month] As nvarchar (10) +'-01 00:00:00'
Between '2017-01-01 00:00:00 'and '2017-02-28 23:59:59'

Declare @ t table (ID int, name varchar (10), time1 datetime, time2 datetime)
Insert @ t select 1, 'A', '2017-5-10 ', '2017-1-1'
Insert @ t select 2, 'A', '2017-11-5 ', null
Insert @ t select 3, 'bb ', '2014-5-10', '2014-2-14'
Insert @ t select 4, 'bb ', '2017-8-23', '2017-1-5'
Insert @ t select 5, 'bb ', '2017-9-14', '2017-4-1'
Insert @ t select 6, 'cc', '2017-2-22 ', null
Insert @ t select 7, 'cc', '2017-10-10 ', '2017-1-10'

Select * From @ t where not exists (select 1 from @ t where name = T. Name and (time1> T. time1 or time2> T. time2 ))

/*
ID name time1 time2
-------------------------------------------------------------------
2 AA 2008-11-05 00:00:00. 000 null
5 BB 00:00:00. 000 00:00:00. 000
6 cc 2009-02-22 00:00:00. 000 null

(3 rows affected)
*/

 

Http://www.cikuu.com/contact.html

Select * From DBO. t_question

Where (tag like n' % card % points % 'and tag not like n' % points % ')

Or (tag not like n' % card % points % 'and tag like n' % points % ')

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.