Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Query help needed
Message
De
28/02/2008 09:33:47
Cetin Basoz
Engineerica Inc.
Izmir, Turquie
 
Information générale
Forum:
Visual FoxPro
Catégorie:
Base de données, Tables, Vues, Index et syntaxe SQL
Divers
Thread ID:
01296873
Message ID:
01297348
Vues:
17
>>And because it should be SQL Server compliant try:
>>That is of course if DateSaved is datetime field.
>>BTW Why not just use Datetime field?
>
>Well I have been witholding some information :) It is not VFP and it is not SQL Server, it is ADS (Advantage Database).
>I am stuck with a table and need to extract some data from it. I only have to do it once so I do not care if it is efficient..
>
>Anywho, there is a DateSaved field (not datetime, just date) and a TimeSaved field (not datetime, just time). I seem to recall that VFP also had just date and just time fields before. ADS is based on DBase like Fox was.
>
>Anywho I got side tracked on my quest for a query but I am hoping to get a chance to look into it this afternoon.

If you don't care about efficiency you could do that using multiple queries which would be easier to follow (and might be much faster too) or a code like this which is ANSI SQL compliant (I think and hpefully supported by ADS):
Select myTable.Sn, myTable.Bal, mt.DateSaved, mt.TimeSaved ;
  FROM myTable ;
  INNER Join ;
  (Select t1.Sn,Md.DateSaved,Max(TimeSaved) As TimeSaved ;
  FROM myTable t1 ;
  INNER Join ;
  (Select Sn,Max(DateSaved) As DateSaved From myTable Group By Sn) Md ;
  ON Md.Sn = t1.Sn And t1.DateSaved = Md.DateSaved ;
  GROUP By t1.sn,md.dateSaved) mt ;
  ON mt.Sn = myTable.Sn ;
  And mt.DateSaved = myTable.DateSaved ;
  And mt.TimeSaved = myTable.TimeSaved
Cetin
Çetin Basöz

The way to Go
Flutter - For mobile, web and desktop.
World's most advanced open source relational database.
.Net for foxheads - Blog (main)
FoxSharp - Blog (mirror)
Welcome to FoxyClasses

LinqPad - C#,VB,F#,SQL,eSQL ... scratchpad
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform