Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Query Related
Message
De
12/07/2004 09:00:01
Hilmar Zonneveld
Independent Consultant
Cochabamba, Bolivie
 
 
À
12/07/2004 08:45:27
Rahul Murarka
Sys-Con Engineering
Kolkata, Inde
Information générale
Forum:
Visual FoxPro
Catégorie:
Codage, syntaxe et commandes
Titre:
Divers
Thread ID:
00923215
Message ID:
00923282
Vues:
31
You can first create a cursor that contains one date for every date in the desired range. Call the cursor "TempDates".

Then, join it with the employee table, using a Cartesian Product:
* The Cartesian Product is on purpose.
select Employee.EmployeeName, Dates.WorkDate;
  from Employee, Dates;
  into cursor TempEmployeeDate
Note that in the above exmaple, a JOIN or WHERE clause is missing - in this case, on purpose!

Since a "Cartesian Product" (caused by a missing JOIN or WHERE clause) is often caused by accident, this should be commented, as above.

Next, combine that with your table below; let's assume it is called WorkData.
select WorkData.*;
  left join TempEmployeeData;
  on WorkData.EmployeeName = TempEmployeeData.EmployeeName;
  and WorkData.WorkDate = TempEmployeeData.WorkDate;
  into cursor TempResult
Missing data should have NULL values in the corresponding fields; for instance, I think that the above code (untested) should give you NULL for "from" and "to".

>Dear Hilmar
>
>When Normal Query is Run My result is
>
>Date Range 1/1/2004 to 7/1/2004
>
>Date Employee From To
>1/1/2004 Rahul 10:40 18:55
>1/1/2004 Anurag 10:40 17:25
>2/1/2004 Anurag 09:10 18:00
>3/1/2004 Rahul 11:35 16:00
>4/1/2004 Rahul 08:00 18:00
>
>The Result I need is
>
>Date Employee From To
>1/1/2004 Rahul 10:40 18:55
>1/1/2004 Anurag 10:40 17:25
>2/1/2004 Anurag 09:10 18:00
>2/1/2004 Rahul Absent
>3/1/2004 Rahul 11:35 16:00
>3/1/2004 Anurag Absent
>4/1/2004 Rahul 08:00 18:00
>4/1/2004 Anurag Absent
>5/1/2004 Rahul Absent
>5/1/2004 Anurag Absent
>6/1/2004 Rahul Absent
>6/1/2004 Anurag Absent
>7/1/2004 Rahul Absent
>7/1/2004 Anurag Absent
>
>What Ever Date Range is Selected For Every Employee a result should be Displayed .If entry is not in Database he is treated as absent.
Difference in opinions hath cost many millions of lives: for instance, whether flesh be bread, or bread be flesh; whether whistling be a vice or a virtue; whether it be better to kiss a post, or throw it into the fire... (from Gulliver's Travels)
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform