Results 1 to 2 of 2

Thread: query help

  1. #1

    Thread Starter
    Frenzied Member wengang's Avatar
    Join Date
    Mar 2000
    Location
    Beijing, China
    Posts
    1,602

    query help

    Hey all.
    I'm just trying to write a short query, but I've forgotten how to do it. I think it involves grouping.
    Access 2010
    Basically, I have two tables, one with a distinct list of Chinese characters (field name Character), the other with a list of words that are made up of combinations of characters.
    I want to retrieve a list of all the characters in tblCharacters that appear in at least 100 records in tblWords (field name Chinese).

    I started with this:

    select A.Character, count(B.ID) as TOTAL from tblCharacters A, tblWords B where Instr(B.Chinese, A.Character) > 0

    I know this query is nonsensical, but I've honestly forgotten how to do it. Here I didn't even try to get at the 100 records, I was just trying to return a complete list of all characters and how many records they had in tblWords and then go from there, but ideally I wanted a list just of the characters that appear in 100 or more words (it's kind of a "useful" characters cut-off list).
    Can anybody fix this for me?
    Thanks.
    Wen Gang, Programmer
    VB6, QB, HTML, ASP, VBScript, Visual C++, Java

  2. #2
    Super Moderator FunkyDexter's Avatar
    Join Date
    Apr 2005
    Location
    An obscure body in the SK system. The inhabitants call it Earth
    Posts
    7,902

    Re: query help

    I think you're almost there but you need a group by and having:-

    Code:
    select A.Character, count(B.ID) as TOTAL 
    from tblCharacters A
    inner join tblWords B 
       on Instr(B.Chinese, A.Character) > 0
    Group By A.Character
    Having count(B.ID) >= 100
    (I also changed it to use an inner join because I find them more readable).
    The best argument against democracy is a five minute conversation with the average voter - Winston Churchill

    Hadoop actually sounds more like the way they greet each other in Yorkshire - Inferrd

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width