Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Query help needed
Message
From
28/02/2008 09:33:47
Cetin Basoz
Engineerica Inc.
Izmir, Turkey
 
General information
Forum:
Visual FoxPro
Category:
Databases,Tables, Views, Indexing and SQL syntax
Miscellaneous
Thread ID:
01296873
Message ID:
01297348
Views:
16
>>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
Previous
Reply
Map
View

Click here to load this message in the networking platform