If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Data Access, Manipulation & Batch Languages > Delphi, C etc > sorting problem

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 02-03-04, 06:45
piulibero piulibero is offline
Registered User
 
Join Date: Dec 2003
Location: Athens,GR
Posts: 16
Unhappy 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.
Reply With Quote
  #2 (permalink)  
Old 02-04-04, 08:50
vududoc vududoc is offline
Registered User
 
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.
Reply With Quote
  #3 (permalink)  
Old 02-04-04, 08:54
piulibero piulibero is offline
Registered User
 
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
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On