Hi all,

Im a bit stuck. I think im staring the answer right in the face but cant see it.

Im after a query that references 1 table.

Its output will be each unique source code along with a total of grouped data from a single column.

SOURCECODE Count of 'yes' count of 'no' count of 'maybe' count of 'dontknow'

any help would be appreciated

SELECT  source, COUNT(*) FROM accounts
AND status = '$type'
GROUP BY source

Recommended Answers

All 3 Replies

SELECT source,count(source) FROM `accounts` group by source

Hi Tiggsy,

Thanks for the reply. That query is fine but what i want is the source name, along with how many of each status there are for that source.

The status column stores 5 different values

You might want to build the query something like this:

SELECT source,status,count(status) from (select source,status from accounts) as subset1 group by source,status
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.