Yes! This works: SELECT surveys.plot_id, IFNULL(species.genus, 'Rodent'), COUNT(IFNULL(species.genus, 'Rodent')) FROM surveys LEFT JOIN species USING (species_id) GROUP BY surveys.plot_id, IFNULL(species.genus, 'Rodent');
Thanks! ~ Amy Amy E. Hodge, PhD Science Data Librarian [email protected]<mailto:[email protected]> 650.556.5194 [cid:[email protected]] orcid.org/0000-0002-5902-3077<https://orcid.org/0000-0002-5902-3077> Data Management Services Branner Earth Sciences Library, 212 Mitchell 397 Panama Mall; MC 2211 Stanford University Stanford, CA 94305 From: "David Martin (Staff)" <[email protected]> Date: Friday, October 20, 2017 at 3:08 PM To: "Amy E. Hodge" <[email protected]>, "[email protected]" <[email protected]> Subject: Re: SQL IFNULL question SELECT surveys.plot_id, IFNULL(species.genus, 'Rodent'), COUNT(IFNULL(species.genus, 'Rodent')) FROM surveys LEFT JOIN species USING (species_id) GROUP BY surveys.plot_id, species.genus;
_______________________________________________ Discuss mailing list [email protected] http://lists.software-carpentry.org/listinfo/discuss
