sql server 2012 - Sql query alteration -


I want this query to work with my table and not just sample data

  Declare the @date variable (8) = '20141013'; With CT (SELECT * FROM) - use your table name instead of values ​​(VALUES ('09: 00: 00', '12:30:00', '7-3', '20140 919' ), ('15:00:00', '17:00:00', '7-2', '20141013'), ('14: 00: 00 ', '16: 00: 00', '7- 3 ',' 20140919 ')) x (EventStart, EventEnd, Rooms, DayStarts)), as cte_Days_Rooms - and specify a day to compare a carti product with all the rooms as well as start and end time ( Select y.EventStart, Y. From EventEnd, x.rooms, (select @date DayStarts) Include a cross.DayStarts (select a separate room from CTE) x CROSS JOIN (choice '09: 00: 00 'EventStart, '09: 00: 00' EventEnd Unions All Selection '22: 00: 00' EventStart, '22: 00: 00' EventEnd) y), as cte_1 - A "Base Data "Merge Original Data (Choose from CTE * Where DayStarts = @ Date Union Select All * from cte_Days_Rooms), as cte_2 - Use the ROW_NUMBER () approach to sort the data (SELECT *, ROW_NUMBER (over) By day, room cte_1 from position) as per order by EventStart - Last Query: Duplicate rows of self, joining with one line offest Destroys one room, starting 09:00 or selecting 22:00 c2a.DayStarts is not finished, c2a.Rooms, c2a .EventEnd, c2b.EventStart interiors c2a cte_2 from c2a.DayStarts = C2b.DayStarts and c2a.Rooms = c2b.Rooms and c2a.pos = c2b.pos -1 Where c2a.EventEnd & lt cte_2 include C2B; & Gt; C2a.DayStarts c2b.EventStart command, c2a.Rooms  

My table is called Events how this looks like my database:

  Event EventStart Event and Days Room Destorts CISC 3660 9: 00 12:30:00 Monday 7-3 9/19/2014 MAT 2501 15:00:00 17:00:00 Monday: Wednesday 7-2 10/13 / 2014 CISC 1110 14:00:00 16:00:00 Monday 7-3 9/19/2014  

This question works well and what happens with that data within the query In line 6 of the query it is said that to when I do assumes that invalid object name is 'Event'. So the question is how can I query the query from my table. Depending on the error message, you may have to enter [schema name].


Comments

Popular posts from this blog

java - Can't add JTree to JPanel of a JInternalFrame -

javascript - data.match(var) not working it seems -

javascript - How can I pause a jQuery .each() loop, while waiting for user input? -