I had a nasty problem that cost me 5 hours. 5 Baffling hours. Life of a newbie.

I wanted to retrieve a simple COUNT from a table, group it by a field "tagname" 
and display the count of each tagname. I have a number of queries with COUNT 
that work fine. But not this time.

AIR would return zero for each tagname. Here's the query:
SELECT COUNT(tagsLU.tagid) as 'tagcount', tag.tagname as 'tagname' FROM TagsLU
Inner Join tag on tag.tagid=tagslu.tagid Group By tag.tagname Order By tagcount
DESC
Here's the expected result, which SQLITE gives me quite generously:

COUNT | TAGNAME
5 school
4 volunteer
2 casual
2 family
1 house
1 work

Except when I called the query from my Flex app, AIR transforms the numbers to 
zero. Big fat 0. I tested and tested, converted the results to an array, tested 
more, and still no luck. Hours. 

I fixed the problem by changing the query. 

While SQLITE is cool with that COUNT(fieldname) statement, AIR doesn't like it. 

But it likes COUNT(*).

SELECT COUNT(*) as 'tagcount', tag.tagname as 'tagname' FROM TagsLU Inner Join 
tag on tag.tagid=tagslu.tagid Group By tag.tagname Order By tagcount DESC

So back to the grind. I hope this helps any other newbies out there.

Reply via email to