Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Group By Date & Type
Message
From
06/09/2006 06:29:49
 
 
To
06/09/2006 03:17:39
Aaron K. Y. Chu
Health & Care Co. Ltd.
Hong Kong, Hong Kong
General information
Forum:
Visual FoxPro
Category:
Databases,Tables, Views, Indexing and SQL syntax
Miscellaneous
Thread ID:
01151212
Message ID:
01151240
Views:
33
>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
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform