0

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.

Matt
  • 14,906
  • 27
  • 99
  • 149
miss
  • 1
  • 1

2 Answers2

0

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) 
Matt
  • 14,906
  • 27
  • 99
  • 149
0

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;

sreesiva
  • 33
  • 5