Re: [sqlite] count from 2 tables

2013-09-04 Thread John McKown
The answer to you exact question is "Yes". Didn't help much did it? But I will at least start off by giving some hints. You need to do an inner join on the common column (service_no). You need to use the HAVING clause to select only those entries with more than 2 entries in the result table

[sqlite] count from 2 tables

2013-09-04 Thread ChingChang Hsiao
There are 2 related table above. There are service_no 1,2,3,5. Service 1,2,3 are type e-line, service 5 is type e-lan. Service 1,2,3 own 2 service_port(sp_no 1,2). Service 5 owns 3 service_port(sp_no 1,2,3). What is the count of services have more than 2 service_port(sp) and type is e-lan?

Re: [sqlite] count from 2 tables

2013-09-03 Thread Igor Tandetnik
On 9/3/2013 6:52 PM, ChingChang Hsiao wrote: What is the count of services have more than 2 service_port(sp) and type is e-lan? The answer is 1. Could it be described as one sql statement? select count(*) from service_table s where service_type = 'e-lan' and (select count(*) from

[sqlite] count from 2 tables

2013-09-03 Thread ChingChang Hsiao
CREATE TABLE service_table ( service_nameTEXT, /* name of the service (unique) */ service_no INTEGER, /* internal service number, assigned by the system. */ service_typeTEXT, /* Type of Service. Should be one of

[sqlite] count from 2 tables

2013-09-03 Thread ChingChang Hsiao
CREATE TABLE service_table ( service_nameTEXT, /* name of the service (unique) */ service_no INTEGER, /* internal service number, assigned by the system. */ service_typeTEXT, /* Type of Service. Should be one of