SQL query/update problem
Date: 16 Aug 1994 17:33:09 -0500
Message-ID: <1994Aug16.102210.22389_at_ucl.ac.uk>
I have a brain teaser, well for me anyway.
I have a database which stores species abundance in the following form:-
COUNTS TABLE SAMPLEID CODE COUNT
1112 A0023D 18 1112 A0021S 1 " A0034F 2
SAMPLES TABLE SAMPLEID TOTCOUNT ....etc
112 21 113 15 114 11 115 78
I created a VIEW which got the sum from COUNTS
# SCRIPT TO CREATE VIEW TOTCOMP */
# To compare counts totals */
create view TOTALCOMP(TOTAL, SAMPID) as
(select sum(COUNT), SAMPLEID from COUNTS
group by COUNTS.SAMPLEID)
and then was able to join this with the totcount field with the following query:-
select TOTAL, TOTCOUNT, SAMPID, SITE, SAMPLENAME
from TOTALCOMP, SAMPLES
where
TOTALCOM.SAMPID = SAMPLES.SAMPLEID
and TOTALCOMP.TOTAL != SAMPLES.TOTCOUNT
- Is there a way of returning the rows where a field is NULL?
- Can this be done in a more efficient way, in a query without a VIEW?
- How should I tackle the update problem?
Any suggestions would be gratefully received.
Thanks
Angus Beare
abeare_at_geog.ucl.ac.uk
UCL, London
Received on Wed Aug 17 1994 - 00:33:09 CEST