CREATE TABLE ALL_PUNCHES_PIVOT2 (ID INT,strcardid NVARCHAR(100),SwipeDate VARCHAR(60),TIME VARCHAR(40));
INSERT INTO ALL_PUNCHES_PIVOT2 (ID,strcardid,SwipeDate,PUNCHTIME)
VALUES (1,'3716817970','01/08/2013','08:47:53')
INSERT INTO ALL_PUNCHES_PIVOT2 (ID,strcardid,SwipeDate,PUNCHTIME)
VALUES (2,'3716817970','01/08/2013','08:47:56')
INSERT INTO ALL_PUNCHES_PIVOT2 (ID,strcardid,SwipeDate,PUNCHTIME)
VALUES (3,'3716817970','01/08/2013','08:52:29')
INSERT INTO ALL_PUNCHES_PIVOT2 (ID,strcardid,SwipeDate,PUNCHTIME)
VALUES (4,'3716817970','01/08/2013','08:52:31')
INSERT INTO ALL_PUNCHES_PIVOT2 (ID,strcardid,SwipeDate,PUNCHTIME)
VALUES (5,'3716817970','01/08/2013','17:50:14')
INSERT INTO ALL_PUNCHES_PIVOT2 (ID,strcardid,SwipeDate,PUNCHTIME)
VALUES (6,'3716817970','01/08/2013','17:50:17')
SELECT * FROM ALL_PUNCHES_PIVOT2;
ID strcardid SwipeDate PunchTime
1 3716817970 01/08/2013 08:47:53
2 3716817970 01/08/2013 08:47:56
3 3716817970 01/08/2013 08:52:29
4 3716817970 01/08/2013 08:52:31
5 3716817970 01/08/2013 17:50:14
6 3716817970 01/08/2013 17:50:17
は今、私は以下パンチの数をピボットする方法SQL Server 2005の1日の時間は?
SELECT * FROM
(
SELECT strcardid,SwipeDate,PunchTime FROM ALL_PUNCHES_PIVOT2
) P
PIVOT (
min([PunchTime]) FOR SwipeDate in ([01/08/2013])
) as Pvt
結果を得るために、ピボットの下に使用しています、私は私が
strcardid Swipedate time1 time2 time3 time4 time5 time6
3716817970 01/08/2013 08:47:53 08:47:56 08:52:29 08:52:31 17:50:14 17:50:17
以下のような出力をする方法をこれまで
strcardid 01/08/2013
3716817970 08:47:53
を取得していた結果であります
私にこれを助けてください
'timeX'の列数は固定されていますか?または、 'time100、....'がある可能性があります。 – valex
時間は最大15 – user3012724