So, in other words in the second count column I would like the result of this:
select p.gp_name as GP, count(d.emis_number) as pat_count from patients p inner join diabetics d on(p.emis_number = d.emis_number) group by GP order by pat_count asc RBS On Sun, 25 Nov 2018, 01:51 Bart Smissaert <bart.smissa...@gmail.com wrote: > Ok, in the first count column I would like the grouped counts for patients > in the views on_non_insulin or on_insulin and > in the second count column I would like the grouped counts for patients > the view diabetics. > Diabetics holds the largest number of ID and the ID's in on_non_insulin > and on_insulin are smaller sub_groups. > > RBS > > On Sun, Nov 25, 2018 at 1:41 AM Igor Tandetnik <i...@tandetnik.org> wrote: > >> On 11/24/2018 7:59 PM, Bart Smissaert wrote: >> > Thanks, was aware, but the SQL was indeed wrong as posted and should >> have >> > brackets around the 2 or conditions. >> >> In this case, as far as I can tell you should end up with diab_count >> equal to pat_count, since "emis_number in(select emis_number from >> diabetics)" is true for every row, guaranteed by the WHERE clause. >> -- >> Igor Tandetnik >> >> >> _______________________________________________ >> sqlite-users mailing list >> sqlite-users@mailinglists.sqlite.org >> http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users >> > _______________________________________________ sqlite-users mailing list sqlite-users@mailinglists.sqlite.org http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users