Results 1 to 3 of 3

Thread: sorting problem

  1. #1
    Join Date
    Dec 2003
    Location
    Athens,GR
    Posts
    16

    Unhappy Unanswered: sorting problem

    i want to modify this table:
    employees----address----phone1----phone2----phone 3
    ----------------------------------------------------------------
    John A. keas 19 9515678
    John A. keas 19 9515670
    Mike B. highway 2 8652332
    Mike B. highway 2 8656543
    Mike B. highway 2 8723165

    like this :
    employees----address----phone1----phone2----phone 3
    ----------------------------------------------------------------
    John A. keas 19 9515678 9515670
    Mike B. highway 2 8652332 8656543 8723165

    _________________________________________________
    may seem silly,i know,but i am stuck here days now and i dont know with what to fill my loop.
    thank you in advance.

  2. #2
    Join Date
    Jul 2001
    Location
    NC
    Posts
    102
    Might I suggest that you normalize your database.

    employeeDB (3 fields): empID, empName, and empAddr
    telephoneDB (2 fields): empID and empPhone

    Using your example data, employeeDB would have 2 records and telephoneDB would have 5 records, 2 for employee with empID=1 and 3 for employee with empID=2. You link the data in the DBs using the empID.

  3. #3
    Join Date
    Dec 2003
    Location
    Athens,GR
    Posts
    16
    i solve it with sql....
    select onoma,odos,thl,
    max(case when c=1 then col end) thl1,
    max(case when c=2 then col end) thl2,
    max(case when c=3 then col end) thl3,
    max(case when c=4 then col end) thl4,
    max(case when c=5 then col end) thl5,
    max(case when c=6 then col end) thl6,
    max(case when c=7 then col end) thl7,
    max(case when c=8 then col end) thl8
    from (select a.onoma, a.odos,a.thl, a.col, count(*) as c
    from forthnetnew as a join forthnetnew as b on a.onoma=b.onoma and a.col <= b.col and a.odos=b.odos
    group by a.onoma, a.odos,a.thl, a.col) x
    group by onoma, odos,thl
    order by onoma

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •