简体   繁体   中英

how to compare two range time for find duplicates records in sql

how to compare two range time for find duplicates records in sql .

Example :-

time_start   time_end

1000         1400

1200         1400

above 1200 to 1400 repeat duplicates time

please help me.

This will get you the difference between the two dates

SELECT DATEDIFF(hh,time_start,time_end)

This will group the duplicates and give you a count

SELECT 
    DATEDIFF(hh,time_start,time_end) AS Diff,
    COUNT(*) AS DuplicateCount
FROM 
    table
DATEDIFF(hh,time_start,time_end) 

you have to fixed the start time as static and end time common.

use this code:

select * from table_name where time_start >= 1200 and time_end <= 1400;

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM