Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Group By Date & Type
Message
De
06/09/2006 06:44:29
 
 
À
06/09/2006 06:29:49
Information générale
Forum:
Visual FoxPro
Catégorie:
Base de données, Tables, Vues, Index et syntaxe SQL
Divers
Thread ID:
01151212
Message ID:
01151242
Vues:
36
>>Dear All,
>>
>>I can't figure out how to do the following:
>>
>>Table Structure
>>1. Punch_Date d,
>>2. Punch_time t,
>>3. time_type n(1) (1=In,2=lunch time begin,3=after lunch,4=out)
>>4. Staff_id n(3)
>>
>>I want to group different time_type by punch_date as follows
>>
>>ddt = datetime(1900,1,1,0,0,0)
>>SELECT punch_date,IIF(time_type=1,punch_time,ddt) as Day_In, IIF(time_type=2,punch_time,ddt) as Lunch_Out,IIF(time_type=3,punch_time,ddt) as Lunch_In, IIF(time_type=4,punch_time,ddt) as Day_Out FROM timecard_log INTO CURSOR timecard_display GROUP BY 1 ORDER BY 1
>>
>>I couldn't do it?!
>>
>
>I tries to guess what do you want.
>
>ddt = datetime(1900,1,1,0,0,0)
>SELECT punch_date ;
>, MAX(IIF(time_type=1,punch_time,ddt)) as Day_In:
>, MAX(IIF(time_type=2,punch_time,ddt)) as Lunch_Out ;
>, MAX(IIF(time_type=3,punch_time,ddt)) as Lunch_In ;
>, MAX(IIF(time_type=4,punch_time,ddt)) as Day_Out ;
>FROM timecard_log INTO CURSOR timecard_display GROUP BY 1 ORDER BY 1
>
>
>>OR
>>
>>
>>SELECT punch_date,IIF(time_type=1,punch_time,dt) as Day_In, IIF(time_type=2,punch_time,dt) as Lunch_Out,IIF(time_type=3,punch_time,dt) as Lunch_In, IIF(time_type=4,punch_time,dt) as Day_Out FROM timecard_log WHERE exist (SELECT punch_date FROM timecard_log GROUP BY 1) INTO CURSOR timecard_display
>>
>>This will create 4 records for each day, instead of 1 record for each day

I think he wants: for every 4 records, recording the 4 punch times of the day, for a particular Staff_ID, one record result, featuring the 4 times. But I don't know how to do it.
- Whoever said that women are the weaker sex never tried to wrest the bedclothes off one in the middle of the night
- Worry is the interest you pay, in advance, for a loan that you may never need to take out.
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform