Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Group By Date & Type
Message
De
06/09/2006 03:17:39
Aaron K. Y. Chu
Health & Care Co. Ltd.
Hong Kong, Hong Kong
 
 
À
Tous
Information générale
Forum:
Visual FoxPro
Catégorie:
Base de données, Tables, Vues, Index et syntaxe SQL
Titre:
Group By Date & Type
Divers
Thread ID:
01151212
Message ID:
01151212
Vues:
81
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?!

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
Best regards,

Aaron Chu

********************************************************

Working with Visual FoxPro is a lot of FUN!

********************************************************
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform