开发者

How do I convert rows to columns in MS Access using Ms-access query(select statment)

开发者 https://www.devze.com 2023-02-11 10:01 出处:网络
please I want help with the following issue: I have the following table named \"CHECKINOUT\" in ms ACCESS

please I want help with the following issue: I have the following table named "CHECKINOUT" in ms ACCESS

     USERID      NAME        CHICKTIME
      1          K1        5:45:11 AM
      1          K1        3:45:12 AM
      1          K1        6:45:11 AM
      1          K1        3:35:13 AM
      1          K1    开发者_运维百科    6:35:14 AM
      1          K1        3:35:15 AM
      1          K1        6:25:16 AM 
      2          K2        3:25:17 AM
      2          K2        5:25:17 AM
      2          K2        3:15:18 AM
      2          K2        3:25:19 AM
      2          K2        4:45:10 AM
      2          K2        2:45:11 AM
      3          K3        7:25:13 AM
      3          K3        6:15:14 AM
      3          K3        5:25:15 AM
      3          K3        3:35:12 AM
      3          K3        5:55:12 AM
      4          K4        5:05:22 AM
      4          K4        4:15:32 AM
      4          K4        3:55:42 AM
      4          K4        1:35:52 AM
      4          K4        2:43:42 AM
      .           .         .
      .           .         .
      .           .         .
      .           .         .

I want to convert the previous table to the get the following result using MS-access query

    USERID      NAME    CHICKIN1    CHECKOUT1    CHICKIN2  CHECKOUT2     CHECKIN3  CHICKOUT 3  CHECKIN 4  CHECKOUT4 CHECKIN5
      1          K1     5:45:11 AM  3:45:12 AM  3:45:12 AM  3:35:15 AM  4:45:10 AM
      2          K2     10:45:12 AM 11:45:12 AM 1:45:12 PM  2:45:12 AM  3:45:12 PM
      3          K3     9:45:12 AM  10:45:12 AM  2:45:12 APM 1:45:12 AM 3:45:12 AM
      4          K4     8:45:12 AM  4:45:12 PM   4:45:12 AM  5:45:12 AM  5:45:12 AM
      .

The CHECKIN, CHECKOUT, COLUMN_NIMBER depend on the data in CHECKTIME for every user.


What you can do is to select and copy the table in Access, and then create an empty file in Excel and then "paste special" and check the "transpose" checkbox. You will get a table of data that switching the original rows and columns.

Now, create the proper table headings in your Access and paste back the data.

0

精彩评论

暂无评论...
验证码 换一张
取 消