• timotech (5/15/2013)


    Hi guys, please i need another help. Please how can i use this particular data:

    Insert into TestTable(AdDate, AdTime, Fk_StationId)

    Select 2013-04-01,07:52:00,A1

    Union All Select 2013-04-01,07:52:43,A1

    Union All Select 2013-04-01,08:05:06,A1

    Union All Select 2013-04-01,08:20:45,A1

    Union All Select 2013-04-02,20:12:38,A1

    Union All Select 2013-04-02, 20:13:10,A1

    Union All Select 2013-04-02, 20:13:10,A1

    Union All Select 2013-04-02, 20:14:00,A1

    Union All Select 2013-04-01,06:00:00,A10

    Union All Select 2013-04-01,06:03:12,A10

    Union All Select 2013-04-01, 06:19:01,A10

    Union All Select 2013-04-01,06:32:31,A10

    Union All Select 2013-04-01, 06:43:36,A10

    Union All Select 2013-04-02, 08:08:54,A10

    Union All Select 2013-04-02, 08:08:54,A10

    Union All Select 2013-04-02, 08:58:46,A10

    Union All Select 2013-04-02, 08:58:46,A10

    To get something like this

    For the first day e.g 1 of 4, 2 of 4 for each Fk_stationId

    Then for the second day also 1 of 4, 2 of 4

    But on running it, its giving me 1 of 8, 2 of 8 since they all belong to the same Fk_StationId

    Please how can i resolve this

    Thanks

    Tim

    First, you really need to test any code you post. What you posted above won't work for several reasons, one of which is there is no CREATE TABLE statement preceeding the INSERT.

    Also, how do you want to handle duplicate entries as you have in your new dataset?