Solved

union query count on word

Posted on 2013-05-19
6
531 Views
Last Modified: 2013-05-19
I have the following which works but i want to count the number of words from each field.

SELECT word2, count([word2]) as countword
from qryword2
union
SELECT word3, count([word3]) as countword
from qryword3
union
SELECT word4, count([word4]) as countword
from qryword4
union
SELECT word5, count([word5]) as countword
from qryword5
union
SELECT word6, count([word6]) as countword
from qryword6
union
SELECT word7, count([word7]) as countword 
from qryword7
UNION
SELECT word8, count([word8]) as countword
from qryword8;

Open in new window

0
Comment
Question by:PeterBaileyUk
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 2
6 Comments
 

Author Comment

by:PeterBaileyUk
ID: 39178494
the counting doesnt work
0
 
LVL 120

Accepted Solution

by:
Rey Obrero (Capricorn1) earned 500 total points
ID: 39178510
SELECT word2 as [Word], count([word2]) as countword
from qryword2
group by word2
union all
SELECT word3 as [Word], count([word3]) as countword
from qryword3
group by word3
union all

etc...
0
 

Author Comment

by:PeterBaileyUk
ID: 39178527
yep worked but i needed sum and to get rid of nulls how do i stop nulls?
SELECT word2, sum([word2]) as countword
from qryword2
where word2 is not null
group by word2
union
SELECT word3, sum([word3]) as countword
from qryword3
where word3 is not null
group by word3
union
SELECT word4, sum([word4]) as countword
from qryword4
where word4 is not null
group by word4; ....
0
Salesforce Made Easy to Use

On-screen guidance at the moment of need enables you & your employees to focus on the core, you can now boost your adoption rates swiftly and simply with one easy tool.

 
LVL 120

Expert Comment

by:Rey Obrero (Capricorn1)
ID: 39178537
yes that is correct,
or you could have done it in the other queries "qryword?"
0
 

Author Comment

by:PeterBaileyUk
ID: 39178542
Yes i did that so no nulls are returned but it says datatype mismatch when i try to use sum?

here is an example output of the sub :
Word2      CountOfWord2
BUSINESS             4
R-DESIGN            17
SE                    15
eeex.PNG
0
 

Author Closing Comment

by:PeterBaileyUk
ID: 39178567
got it thank you:

SELECT word2, sum([countofword2]) as countword2
from qryword2
group by word2
union
SELECT word3, sum([countofword3]) as countword3
from qryword3
group by word3
union
SELECT word4, sum([countofword4]) as countword4
from qryword4
group by word4
union
SELECT word5, sum([countofword5]) as countword5
from qryword5
group by word5
union
SELECT word6, sum([countofword6]) as countword6
from qryword6
group by word6
union
SELECT word7, sum([countofword7]) as countword7
from qryword7
group by word7
union
SELECT word8, sum([countofword8]) as countword8
from qryword8
group by word8;
0

Featured Post

U.S. Department of Agriculture and Acronis Access

With the new era of mobile computing, smartphones and tablets, wireless communications and cloud services, the USDA sought to take advantage of a mobilized workforce and the blurring lines between personal and corporate computing resources.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Preparing an email is something we should all take special care with – especially when the email is for somebody you may not know very well. The pressures of everyday working life stacked with a hectic office environment can make this a real challen…
This article describes two methods for creating a combo box that can be used to add new items to the row source -- one for simple lookup tables, and one for a more complex row source where the new item needs data for several fields.
Using Microsoft Access, learn some simple rules for how to construct tables in a relational database. Split up all multi-value fields into single values: Split up fields that belong to other things into separate tables: Make sure that all record…
With Microsoft Access, learn how to specify relationships between tables and set various options on the relationship. Add the tables: Create the relationship: Decide if you’re going to set referential integrity: Decide if you want cascade upda…

726 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question