Click here to Skip to main content
15,886,137 members
Home / Discussions / Database
   

Database

 
Questioninvalid parameter value on CreateSubscription Pin
run4ever_771-Apr-11 2:40
run4ever_771-Apr-11 2:40 
QuestionHarmless joke or mean prank Pin
shelbypowell1-Apr-11 1:14
shelbypowell1-Apr-11 1:14 
QuestionSelecting from an XML datatype into a table Pin
Mel Padden31-Mar-11 23:47
Mel Padden31-Mar-11 23:47 
AnswerRe: Selecting from an XML datatype into a table Pin
Mel Padden1-Apr-11 0:01
Mel Padden1-Apr-11 0:01 
QuestionSQL question Pin
loyal ginger31-Mar-11 8:14
loyal ginger31-Mar-11 8:14 
QuestionRe: SQL question Pin
Jörgen Andersson31-Mar-11 8:45
professionalJörgen Andersson31-Mar-11 8:45 
GeneralRe: SQL question Pin
loyal ginger31-Mar-11 9:06
loyal ginger31-Mar-11 9:06 
GeneralRe: SQL question [modified] Pin
Jörgen Andersson31-Mar-11 9:38
professionalJörgen Andersson31-Mar-11 9:38 
Ok, this one works with your example: No it doesn't, it'll give you the combined stretches of road with gaps between them
WITH t1 AS (
    SELECT  r1.RoadID,r1.BEGIN
    FROM    Roads r1 Left outer join Roads r2
        ON  r1.RoadID = r2.RoadID
        AND r1.BEGIN > r2.BEGIN
        AND r1.BEGIN <= r2.END
    GROUP BY r1.RoadID,r1.BEGIN
    HAVING  Count(r2.BEGIN) = 0
    )
,t2 AS (
    SELECT  r3.RoadID,r3.END
    FROM    Roads r3 Left outer join Roads r4
        ON  r3.RoadID = r4.RoadID
        AND r3.END >= r4.BEGIN
        AND r3.END < r4.END
    GROUP BY r3.RoadID,r3.END
    HAVING  Count(r4.BEGIN) = 0
    )
,ContiguousStretch AS (
    SELECT  t1.RoadID,t1.BEGIN,Min(t2.END) AS END
    FROM    t1 join t2
        ON  t1.RoadID = t2.RoadID
        AND t1.BEGIN <= t2.END
    GROUP BY t1.RoadID,t1.BEGIN
    )
,Gaps AS (
    SELECT  RoadID
    FROM    ContiguousStretch
    GROUP BY RoadID
    HAVING  Count(RoadID) > 1
    )
SELECT  c.RoadID,BEGIN,END
FROM    ContiguousStretch c join gaps g
    ON  c.RoadID = g.RoadID
ORDER BY c.RoadID,BEGIN

List of common misconceptions
modified on Thursday, March 31, 2011 3:45 PM

GeneralRe: SQL question Pin
loyal ginger31-Mar-11 10:16
loyal ginger31-Mar-11 10:16 
AnswerRe: SQL question Pin
Jörgen Andersson31-Mar-11 10:28
professionalJörgen Andersson31-Mar-11 10:28 
GeneralRe: SQL question Pin
loyal ginger1-Apr-11 3:23
loyal ginger1-Apr-11 3:23 
AnswerRe: SQL question Pin
Wendelius31-Mar-11 9:14
mentorWendelius31-Mar-11 9:14 
GeneralRe: SQL question Pin
loyal ginger31-Mar-11 10:17
loyal ginger31-Mar-11 10:17 
QuestionThis one has me stumped Pin
Andy Brummer31-Mar-11 6:01
sitebuilderAndy Brummer31-Mar-11 6:01 
AnswerRe: This one has me stumped Pin
Wendelius31-Mar-11 6:45
mentorWendelius31-Mar-11 6:45 
Generalvirtual keyboard Pin
shelbypowell31-Mar-11 4:02
shelbypowell31-Mar-11 4:02 
GeneralRe: virtual keyboard Pin
Mycroft Holmes31-Mar-11 13:09
professionalMycroft Holmes31-Mar-11 13:09 
GeneralRe: virtual keyboard Pin
shelbypowell31-Mar-11 13:58
shelbypowell31-Mar-11 13:58 
GeneralRe: virtual keyboard Pin
Mycroft Holmes31-Mar-11 14:17
professionalMycroft Holmes31-Mar-11 14:17 
GeneralRe: virtual keyboard Pin
Pete O'Hanlon31-Mar-11 23:35
mvePete O'Hanlon31-Mar-11 23:35 
GeneralRe: virtual keyboard Pin
Andy_L_J31-Mar-11 23:56
Andy_L_J31-Mar-11 23:56 
GeneralRe: virtual keyboard Pin
shelbypowell1-Apr-11 1:05
shelbypowell1-Apr-11 1:05 
QuestionPlease modify the Stored procedure (Error:-incorrect syntax near '+') Pin
vinu.111131-Mar-11 2:17
vinu.111131-Mar-11 2:17 
AnswerRe: Please modify the Stored procedure (Error:-incorrect syntax near '+') Pin
s_magus31-Mar-11 3:47
s_magus31-Mar-11 3:47 
AnswerRe: Please modify the Stored procedure (Error:-incorrect syntax near '+') Pin
Wendelius31-Mar-11 5:30
mentorWendelius31-Mar-11 5:30 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.