Information générale
Catégorie:
Base de données, Tables, Vues, Index et syntaxe SQL
Titre:
Full outer join problem
Hi all,
I can't get an SQL query to work properly, & am hoping that the SQL experts among you may be able to help.
I have 2 tables:
-'Agesex'- a 'lookup' table for age/sex groups, eg:
Agegp Sex
00-04 0
00-04 1
05-14 0
05-14 1
- 'Tmp3' - a table of the number of patients (cnt) GP's (gpcode) have of each age/sex group, eg:
Gpcode Agegp Sex Cnt
00001 00-04 0 204
00001 00-04 1 180
00001 05-14 0 79
00001 05-14 1 96
What I'd like is to outer join the tables so that the full 'Agesex' table is reproduced for every Gpcode, even when a GP has no patients of a particular age/sex group. I've tried the following without luck, so any help appreciated.
SELECT t.*, a.agegp as aagegp, a.sex as asex from agesex a FULL OUTER JOIN tmp3 t ON a.agegp=t.agegp AND a.sex=t.sex INTO TABLE tmp5 DATABASE raw ORDER BY gpcode, a.agegp, a.sex
TIA.
Suivant
Répondre
Voir le fil de ce thread
Voir le fil de ce thread à partir de ce message seulement
Voir tous les messages de ce thread
Voir tous les messages de ce thread à partir de ce message seulement