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

Database

 
AnswerRe: Log shipping of SQL2012 databases failing Pin
jschell12-Jan-14 9:17
jschell12-Jan-14 9:17 
GeneralRe: Log shipping of SQL2012 databases failing Pin
Chris Quinn12-Jan-14 20:55
Chris Quinn12-Jan-14 20:55 
GeneralRe: Log shipping of SQL2012 databases failing Pin
jschell13-Jan-14 9:07
jschell13-Jan-14 9:07 
QuestionQuery in SQL Server or Oracles Pin
mrkeivan8-Jan-14 22:22
mrkeivan8-Jan-14 22:22 
QuestionRe: Query in SQL Server or Oracles Pin
Jörgen Andersson8-Jan-14 22:34
professionalJörgen Andersson8-Jan-14 22:34 
AnswerRe: Query in SQL Server or Oracles Pin
mrkeivan9-Jan-14 10:28
mrkeivan9-Jan-14 10:28 
GeneralRe: Query in SQL Server or Oracles Pin
Mycroft Holmes9-Jan-14 11:42
professionalMycroft Holmes9-Jan-14 11:42 
AnswerRe: Query in SQL Server or Oracles Pin
Jörgen Andersson11-Jan-14 10:00
professionalJörgen Andersson11-Jan-14 10:00 
Try something like this:
SQL
WITH Entries AS (
    SELECT  PlateNumber
           ,DATE
           ,RoadName
    FROM    EMSINFO e
           ,Devices d
           ,Roads r
    WHERE   e.deviceID = d.DeviceID
    AND     d.RoadID = r.RoadID
    AND     d.InOut = 'IN'
    )
,Exits AS (   
    SELECT  e.PlateNumber
           ,e2.DATE EntryTime
           ,e2.RoadName EntryRoad
           ,Min(DATE) ExitTime
    FROM    Entries e2
           ,EMSINFO e
           ,Devices d
    WHERE   e2.platenumber = e.platenumber
    AND     e.deviceID = d.DeviceID
    AND     d.InOut = 'OUT'
    AND     e.DATE > e2.DATE
    GROUP BY e.PlateNumber
            ,e2.DATE
            ,e2.RoadName
    )
SELECT  e.PlateNumber
       ,EntryTime
       ,EntryRoad
       ,ExitTime
       ,r.RoadName ExitRoad
FROM    Exits e
       ,EMSINFO e2
       ,devices d
       ,Roads r
WHERE   e.platenumber = e2.platenumber
AND     e.ExitTime = e2.DATE
AND     e2.DeviceID = d.DeviceID
AND     d.RoadID = r.RoadID

There are probably better implementations to your problem, Search for sql+islands+and+gaps[^].
"Islands and Gaps" is the name of this classic problem.
Wrong is evil and must be defeated.
- Jeff Ello[^]

GeneralRe: Query in SQL Server or Oracles Pin
mrkeivan14-Jan-14 11:48
mrkeivan14-Jan-14 11:48 
Questionhow to use sub report in rdlc Pin
mhd.sbt6-Jan-14 22:12
mhd.sbt6-Jan-14 22:12 
Question[solved] unknown syntax of stored procedure Pin
delosb6-Jan-14 4:33
delosb6-Jan-14 4:33 
AnswerRe: unknown syntax of stored procedure Pin
Peter Leow6-Jan-14 5:00
professionalPeter Leow6-Jan-14 5:00 
GeneralRe: unknown syntax of stored procedure Pin
delosb6-Jan-14 5:12
delosb6-Jan-14 5:12 
GeneralRe: unknown syntax of stored procedure Pin
Peter Leow6-Jan-14 5:20
professionalPeter Leow6-Jan-14 5:20 
Questioni want to write a optimal query for a complex problem Pin
mhd.sbt5-Jan-14 22:32
mhd.sbt5-Jan-14 22:32 
QuestionRe: i want to write a optimal query for a complex problem Pin
Jörgen Andersson6-Jan-14 1:41
professionalJörgen Andersson6-Jan-14 1:41 
QuestionHow to loop or something a temp distinct table to sum up the totals Pin
jkirkerx3-Jan-14 10:38
professionaljkirkerx3-Jan-14 10:38 
AnswerRe: How to loop or something a temp distinct table to sum up the totals Pin
Jörgen Andersson4-Jan-14 19:00
professionalJörgen Andersson4-Jan-14 19:00 
GeneralRe: How to loop or something a temp distinct table to sum up the totals Pin
jkirkerx4-Jan-14 19:38
professionaljkirkerx4-Jan-14 19:38 
GeneralRe: How to loop or something a temp distinct table to sum up the totals Pin
Jörgen Andersson4-Jan-14 21:04
professionalJörgen Andersson4-Jan-14 21:04 
GeneralRe: How to loop or something a temp distinct table to sum up the totals Pin
jkirkerx5-Jan-14 7:57
professionaljkirkerx5-Jan-14 7:57 
GeneralRe: How to loop or something a temp distinct table to sum up the totals Pin
jkirkerx5-Jan-14 8:29
professionaljkirkerx5-Jan-14 8:29 
GeneralRe: How to loop or something a temp distinct table to sum up the totals Pin
Christian Graus5-Jan-14 16:02
protectorChristian Graus5-Jan-14 16:02 
GeneralRe: How to loop or something a temp distinct table to sum up the totals Pin
Jörgen Andersson5-Jan-14 22:19
professionalJörgen Andersson5-Jan-14 22:19 
GeneralRe: How to loop or something a temp distinct table to sum up the totals Pin
jkirkerx6-Jan-14 6:06
professionaljkirkerx6-Jan-14 6:06 

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.