11.521: Computer-Based Analysis for Public Management |
11.523: Fundamentals of Spatial Database Management |
11.524: Advanced Geographic Information System Project |
select p.parcelid, add1, add2, count(fdate) firesThis set of queries will save the results of the previous join in a table and then add in one row for every parcel in the parcel table that didn't have a fire:
from parcels p, fires f
where p.parcelid = f.parcelid
group by p.parcelid, add1, add2;
create table t1holdf asNow, here's an 'outer join' SQL statement that redoes the original query in a way that adds
select p.parcelid, add1, add2, count(fdate) fires
from parcels p, fires f
where p.parcelid = f.parcelid
group by p.parcelid, add1, add2;insert into t1holdf
select parcelid, add1, add2, 0
from parcels
where parcelid NOT IN (select parcelid from fires);
select p.parcelid, add1, add2,
count(fdate) fires, sum(estloss)
from parcels p, fires
f
where p.parcelid = f.parcelid
(+)
group by p.parcelid, add1, add2;
Back to the 11.521
Home Page
Back to the CRL Home
Page
Back to the MIT Home
Page
For more information about this page, please contact the 11.521 Staff Mailing List <11.521staff@MIT.EDU>.
Written by Joseph Ferreira, Jr. on 9 Oct. 1997.
Converted to HTML by Thomas H. Grayson on 1 Feb. 2000.
Last modified: 1 February 2000 [thg]