Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
VFP SQL Syntax - Tuesday BrainFreeze
Message
De
10/07/2007 13:26:45
Cetin Basoz
Engineerica Inc.
Izmir, Turquie
 
 
À
10/07/2007 13:01:12
Information générale
Forum:
Visual FoxPro
Catégorie:
Base de données, Tables, Vues, Index et syntaxe SQL
Versions des environnements
Visual FoxPro:
VFP 9 SP1
OS:
Windows XP SP2
Network:
Windows 2003 Server
Database:
MS SQL Server
Divers
Thread ID:
01238981
Message ID:
01238998
Vues:
8
>All fields are character.
>
>Table1 fields:
>
>aid
>aagcy
>adescriptn
>
>Table2 fields:
>
>bidv (same value as aid in table1)
>bname
>bvalue
>
>I want to join the above two tables and do the following:
>
>1. Create a single record for every distinct or unique aid record in table1 whether or not a match exists in table2.
>2. Include the fields: table1.aid, table1.aagcy, table2.bvalue
>3. If there is no matching record in table2, then I want to populate the bvalue field in the joined cursor with an empty string value ''.
>
>I am stuck on a simple sql statement which amazes me. I just can't concentrate today :o( Maybe it was the only 2 hours of sleep I got last night? :o)
select aid, max(aagcy) as aagcy, max(adescriptn) as adescriptn, ;
 max(nvl(bvalue, '')) as bvalue ;
 from table1 ;
 left join table2 on table1.aaid == table2.bidv ;
 group by 1
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