Need query help for the following I have a sample data, as below on one of my table.
Create table #MovieShows(Id int, Movieid varchar(20), Showtime time)
insert into #MovieShows values (11,'m1','13:00')
insert into #MovieShows values (23,'m2','14:00')
insert into #MovieShows values (34,'m1','15:00')
insert into #MovieShows values (45,'m2','16:00')
insert into #MovieShows values (55,'m2','20:00')
insert into #MovieShows values (64,'m1','16:00')
insert into #MovieShows values (66,'m2','21:00')
insert into #MovieShows values (81,'m1','20:00')
go
select * from #MovieShows order by Movieid, id
==========================
Need a query to show the missing rows along with table rows.
Desired output should be
Id MovieID Showtime
11 m1 13:00
11 m1 14:00 --New row
34 m1 15:00
64 m1 16:00
64 m1 17:00 --New row
64 m1 18:00 --New row
64 m1 19:00 --New row
81 m1 20:00
23 m2 14:00
23 m2 15:00 --New row
45 m2 16:00
45 m2 17:00 --New row
45 m2 18:00 --New row
45 m2 19:00 --New row
55 m2 20:00
66 m2 21:00
The query needs to show the missing rows with respect to time sequence, along with the table rows. The missing rows needs to be interleaved among the table rows.
idcolumn. How do you determine theidfor a non-matching row?