Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Query help needed
Message
From
27/02/2008 11:07:24
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:
01296879
Views:
12
>Consider the table:
>
>Sn   Bal  DateSaved  TimeSaved
>1    200  2/5/2008   10:00
>1    175  2/5/2008   11:00
>1    123  2/5/2008   13:00
>1    111  2/6/2008   08:00
>1    101  2/6/2008   18:00
>2    500  2/8/2008   10:00
>2    475  2/8/2008   11:00
>
>
>I am trying write a query that will give me the following result set
>
>Sn   Bal  DateSaved  TimeSaved
>1    101  2/6/2008   18:00
>2    475  2/8/2008   11:00
>
>
>1 record per Sn where the DateSaved and the TimeSaved (together) is the newest datetime.
>
>Thanks,
>Einar
select * from myTable t1 ;
 where ttoc(dtot(DateSaved)+(ctot(TimeSaved)-ctot('0')),1) = ;
  (select max(ttoc(dtot(DateSaved)+(ctot(TimeSaved)-ctot('0')),1)) ;
    from myTable t2 where t1.sn = t2.sn)
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