Hi,
If the union all query is saved under the name QU, then
TRANSFORM COUNT(*)
SELECT 1
FROM qu
GROUP BY 1
PIVOT TheNumber
should do.
Hoping it may help,
Vanderghast, Access MVP
Yep, I did, but Michel had helped me on another query, so I
figured.....
My
db has 6 fields all populated with numbers from 01-55 and there are
1404
records. How can I write a query to tell me how many time each of the
numbers
(say number 8 comes up) in all of the fields? No error message, just
does
not return any results.
:
It would really be better to start your own thread. It stands out as
being a
question you asked. By the way, what is your question? Did your
attempt
fail?
Did you get an error message? Did you get the wrong results? Are you
trying to
restrict the query to just one number?
Your queries LOOK as if they should work.
SELECT pb.[pb1] as TheNumber
FROM PB
UNION ALL
SELECT pb.[pb2]
FROM PB
UNION ALL
SELECT pb.[pb3]
FROM PB
UNION ALL
SELECT pb.[pb4]
FROM PB
UNION ALL
SELECT pb.[pb5]
FROM PB
UNION ALL SELECT pb.[pb6]
FROM PB;
SELECT TheNumber, Count(TheNumber)
FROM quniNumbers
GROUP BY TheNumber
tamxwell wrote:
Hi Michel,
I have a query that I've tried a number of ways. My db has 6 fields
all
populated with numbers from 01-55 and there are 1404
records. How can I write a query to tell me how many time each of
the
numbers
(say number 8 comes up) in all of the fields? Here's a look at it.
You
helped me with the UNION before. I'll list the UNION, then the Count
query
SELECT pb.[pb1] as TheNumber,1 As CountofmyNumber
FROM PB
UNION ALL
SELECT pb.[pb2],2
FROM PB
UNION ALL
SELECT pb.[pb3],3
FROM PB
UNION ALL
SELECT pb.[pb4],4
FROM PB
UNION ALL
SELECT pb.[pb5],5
FROM PB
UNION ALL SELECT pb.[pb6],6
FROM PB;
Then I wrote this to do the actual count, nada?
SELECT [TheNumber], Count([TheNumber]) AS CountOf
FROM quniNumbers
GROUP BY [TheNumber];