Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Group By Date & Type
Message
General information
Forum:
Visual FoxPro
Category:
Databases,Tables, Views, Indexing and SQL syntax
Miscellaneous
Thread ID:
01151212
Message ID:
01151266
Views:
39
>>>>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.
>
>Fabio's first suggestion will do this.
>HA! Again with old picture?

I thought the SQL was getting the max() of all the time values into one rec for all the days that the person has punched in and out?

What you mean "HA! Again with old picture?"?
- 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.
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform