我在我們的日常時間記錄 中對數據進行分組和排序時出現問題以自動生成報告。 的DTR
爲表結構如下:複雜的SQL排序和分組
Log Date Log Time Employee Name Log Type 9/13/2012 17:00:00 SALITA, LYNYRD ANTONIO LOGOUT 9/13/2012 8:05:00 SALITA, LYNYRD ANTONIO LOGIN 9/12/2012 17:05:00 SALITA, LYNYRD ANTONIO LOGOUT 9/12/2012 8:05:00 SALITA, LYNYRD ANTONIO LOGIN 7/10/2012 17:00:00 GARCIA, ALVIN LOGOUT 7/10/2012 17:00:00 AURENO, LEAH LOGOUT 7/10/2012 17:00:00 SALITA, LYNYRD ANTONIO LOGOUT 7/10/2012 17:00:00 CANSINO, PAUL LOGOUT 7/10/2012 17:00:00 BELO, RIO LOGOUT 7/10/2012 17:00:00 MAG-ISA, MAYBELLE LOGOUT 7/10/2012 17:00:00 TARINE, KAREN LOGOUT 7/10/2012 17:00:00 REYES, ANDREA LOGOUT 7/10/2012 17:00:00 NAVARRO, KRISTINA LOGOUT 7/10/2012 10:30:00 MAG-ISA, MAYBELLE LOGIN 7/10/2012 8:00:00 SALITA, LYNYRD ANTONIO LOGIN 7/10/2012 8:00:00 CANSINO, PAUL LOGIN 7/10/2012 8:00:00 BELO, RIO LOGIN 7/10/2012 7:40:00 AURENO, LEAH LOGIN 7/10/2012 7:30:00 GARCIA, ALVIN LOGIN 7/10/2012 7:25:00 TARINE, KAREN LOGIN 7/10/2012 7:10:00 NAVARRO, KRISTINA LOGIN 7/10/2012 7:10:00 REYES, ANDREA LOGIN
我想它要處理的查詢,像這樣的輸出:
Log Date Employee Name LOGIN LOGOUT 9/13/2012 SALITA, LYNYRD ANTONIO 8:05:00 17:00:00 9/12/2012 SALITA, LYNYRD ANTONIO 8:05:00 17:05:00 7/10/2012 GARCIA, ALVIN 7:30:00 17:00:00 7/10/2012 AURENO, LEAH 7:40:00 17:00:00 7/10/2012 SALITA, LYNYRD ANTONIO 8:00:00 17:00:00 7/10/2012 CANSINO, PAUL 8:00:00 17:00:00 7/10/2012 BELO, RIO 8:00:00 17:00:00 7/10/2012 MAG-ISA, MAYBELLE 10:30:00 17:00:00 7/10/2012 TARINE, KAREN 7:25:00 17:00:00 7/10/2012 REYES, ANDREA 7:10:00 17:00:00 7/10/2012 NAVARRO, KRISTINA 7:10:00 17:00:00
如何實現這一目標?
Wich RDBMS:MS SQL Server,MySQL,Postgre,Oracle?而且,你有什麼嘗試?發佈一個工作查詢,不管其錯誤,也許你只是一步接近解決方案 – Yaroslav