Hi, I'm trying to count two different column combinations using two tables.
Table one (tag_name) contains the 'id' and the 'name' for a tag. Table two
is stuffed with entries that links those tags with different applications
and their contents.
Now I would like to select how often each tag is used in each application.
Some of my previous tries worked fine (using JOIN ON) – but only one COUNT
was possible. Now I'm trying to get a statement to work which returns me the
tag amounts for both apps.

tag_name
id | tag
--------
1 | sql
2 | xml
3 | foo

tag_link
id | app | app_id | tag_id
----------------------------
1  | d    | 331     | 2
2  | t     | 49      | 1

Here is my current statement:
SELECT 
        tag_name.id,
        (SELECT COUNT(*) FROM tag_link WHERE tag_link.tag_id = tag_name.id AND
tag_link.app = 't') AS cntTwt,
        (SELECT COUNT(*) FROM tag_link WHERE tag_link.tag_id = tag_name.id AND
tag_link.app = 'd') AS cntDel
FROM 
        tag_name 
GROUP BY 
        tag_name.id

The parser returns no error, only seems to freeze. Tipps, hints – all kind
of advice.
sincerely, ckeen
-- 
View this message in context: 
http://www.nabble.com/Multiple-counts-between-two-tables-tp23473911p23473911.html
Sent from the SQLite mailing list archive at Nabble.com.

_______________________________________________
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users

Reply via email to