Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Inexact SQL match
Message
 
 
À
20/05/2001 22:49:37
Information générale
Forum:
Visual FoxPro
Catégorie:
Base de données, Tables, Vues, Index et syntaxe SQL
Divers
Thread ID:
00509308
Message ID:
00509348
Vues:
14
Hi!

Name and BillAmt have no sense in such queries with aggreagate functions, because there might be more than one record with max(dt). You require to query these data another way:

SELECT name, dt, billamt from patient,visit where
dt IN (SELECT max(dt) from patient,visit WHERE year(dt)<=1999)

This way you get all records which have max(dt) and correct related fields.

Take a look also to the help in MSDN for SELECT statement. I recommend you to read specially chpters related to JOINS and WHERE. I guess this query is way too slow because you link 2 tables in a full join.

HTH.

>Hi every VFP users, I need to do an inexact SQL match between 2 or more tables but couldn't get it to work the way I want it. I have a patients table and a medical visits table. I need to find the last visit record of each patient in the year 1999. My SQL goes somthing like this.
>
>SELECT name, max(dt), billamt from patient,visit where year(dt)<=1999
>
>I could get the right date but the bill amount does not retrieve correctly from the last visit record for year 1999.
>
>Best regards
Vlad Grynchyshyn, Project Manager, MCP
vgryn@yahoo.com
ICQ #10709245
The professional level of programmer could be determined by level of stupidity of his/her bugs

It is not appropriate to say that question is "foolish". There could be only foolish answers. Everybody passed period of time when knows nothing about something.
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform