Click here to Skip to main content
15,914,071 members
Home / Discussions / Database
   

Database

 
QuestionProper databse for a seatmap/multiple? Pin
Yhen Caisip18-Jan-14 3:05
Yhen Caisip18-Jan-14 3:05 
AnswerRe: Proper databse for a seatmap/multiple? Pin
Peter Leow18-Jan-14 3:25
professionalPeter Leow18-Jan-14 3:25 
GeneralRe: Proper databse for a seatmap/multiple? Pin
Yhen Caisip18-Jan-14 4:06
Yhen Caisip18-Jan-14 4:06 
SuggestionRe: Proper databse for a seatmap/multiple? Pin
Peter Leow18-Jan-14 4:50
professionalPeter Leow18-Jan-14 4:50 
GeneralRe: Proper databse for a seatmap/multiple? Pin
Yhen Caisip18-Jan-14 6:00
Yhen Caisip18-Jan-14 6:00 
AnswerRe: Proper databse for a seatmap/multiple? Pin
Jörgen Andersson18-Jan-14 4:24
professionalJörgen Andersson18-Jan-14 4:24 
Questionoracle database 10g SCN Number change Pin
vinayak sharma16-Jan-14 5:43
vinayak sharma16-Jan-14 5:43 
AnswerRe: oracle database 10g SCN Number change Pin
Shameel21-Jan-14 23:37
professionalShameel21-Jan-14 23:37 
Questionpostgresql issues Pin
aswadmanap14-Jan-14 22:35
aswadmanap14-Jan-14 22:35 
AnswerRe: postgresql issues Pin
Eddy Vluggen15-Jan-14 0:31
professionalEddy Vluggen15-Jan-14 0:31 
GeneralRe: postgresql issues Pin
aswadmanap15-Jan-14 15:10
aswadmanap15-Jan-14 15:10 
QuestionRe: postgresql issues Pin
Eddy Vluggen16-Jan-14 10:34
professionalEddy Vluggen16-Jan-14 10:34 
AnswerRe: postgresql issues Pin
Bernhard Hiller15-Jan-14 21:52
Bernhard Hiller15-Jan-14 21:52 
GeneralRe: postgresql issues Pin
aswadmanap21-Jan-14 17:14
aswadmanap21-Jan-14 17:14 
QuestionCreate multiple tables with a single SQL query Pin
Richard Fernandes, Dubai, UAE14-Jan-14 22:35
Richard Fernandes, Dubai, UAE14-Jan-14 22:35 
AnswerRe: Create multiple tables with a single SQL query Pin
Chris Quinn14-Jan-14 23:56
Chris Quinn14-Jan-14 23:56 
AnswerRe: Create multiple tables with a single SQL query Pin
Eddy Vluggen15-Jan-14 0:28
professionalEddy Vluggen15-Jan-14 0:28 
GeneralRe: Create multiple tables with a single SQL query Pin
Shameel16-Jan-14 3:38
professionalShameel16-Jan-14 3:38 
GeneralRe: Create multiple tables with a single SQL query Pin
Eddy Vluggen16-Jan-14 11:16
professionalEddy Vluggen16-Jan-14 11:16 
SuggestionRe: Create multiple tables with a single SQL query Pin
Richard Deeming15-Jan-14 1:04
mveRichard Deeming15-Jan-14 1:04 
AnswerRe: Create multiple tables with a single SQL query Pin
King Fisher30-Jan-14 2:19
professionalKing Fisher30-Jan-14 2:19 
QuestionProcessing records in select statement in Oracle DB Pin
mrkeivan14-Jan-14 19:39
mrkeivan14-Jan-14 19:39 
AnswerRe: Processing records in select statement in Oracle DB Pin
Jörgen Andersson15-Jan-14 0:12
professionalJörgen Andersson15-Jan-14 0:12 
Have a look at this query:
SQL
WITH passes AS (
    SELECT  platenumber
           ,DATE
           ,InOut
           ,RoadName
           ,LEAD(InOut, 1, null) OVER (PARTITION BY platenumber ORDER BY date NULLS LAST) NEXT_InOut
           ,LEAD(RoadName, 1, null) OVER (PARTITION BY platenumber ORDER BY date NULLS LAST) NEXT_RoadName
           ,LEAD(Date, 1, null) OVER (PARTITION BY platenumber ORDER BY date NULLS LAST) NEXT_Date
    FROM    EMSINFO e
           ,Devices d
           ,Roads r
    WHERE   e.deviceID = d.DeviceID
    AND     d.RoadID = r.RoadID
    )
SELECT  platenumber
       ,DATE entrytime
       ,RoadName entryroad
       ,NEXT_RoadName exitroad
       ,NEXT_Date exittime
FROM    passes
WHERE   InOut = 'IN'
AND     NEXT_InOut = 'OUT'
Here I'm assuming that you have the same table structure as in the last question.
Using the analytic function LEAD you can work on the next row, so in this query I'm making sure that the row after the inwards passage is an outwards passage.
Adjust to your needs.

Remember that analytic functions are the last set of operations performed in a query except for the final ORDER BY clause. So if you need to do more work on the data you have to use a CTE. (Like I did)
Wrong is evil and must be defeated.
- Jeff Ello[^]

GeneralRe: Processing records in select statement in Oracle DB Pin
mrkeivan15-Jan-14 0:43
mrkeivan15-Jan-14 0:43 
GeneralRe: Processing records in select statement in Oracle DB Pin
Jörgen Andersson15-Jan-14 21:25
professionalJörgen Andersson15-Jan-14 21:25 

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.