query question

Discussion in 'MS Access' started by jumpingtree, Sep 6, 2010.

  1. jumpingtree

    jumpingtree New Member

    Joined:
    Sep 6, 2010
    Messages:
    1
    Likes Received:
    0
    Trophy Points:
    0
    how to adapt the fragment of code below to show:
    a) Two columns - the Filipino Population and the Total Population
    b) The Filipino Population as a percentage of the total population

    SELECT DISTINCTROW POPDATA.CITYNUM,
    COUNT (*) FROM POPDATA
    WHERE POPDATA.ANCNUMBER=720
    GROUP BY POPDATA. CITYNUM
    ORDER BY COUNT (*) DESC;


     
  2. apr pillai

    apr pillai New Member

    Joined:
    Dec 17, 2010
    Messages:
    16
    Likes Received:
    12
    Trophy Points:
    0
    Occupation:
    Auditor
    Location:
    India
    Home Page:
    http://www.msaccesstips.com/
    Modify the SQL as given below:

    Code:
    SELECT DISTINCTROW POPDATA.CITYNUM,
    
    COUNT(POPDATA.CITYNUM) AS COUNT,
    DCOUNT("*","POPDATA") AS TOTAL
    count(POPDATA.CITYNUM)/DCOUNT("*","POPDATA") AS PERCENTAGE
    
    FROM POPDATA
    WHERE POPDATA.ANCNUMBER=720
    GROUP BY POPDATA. CITYNUM
    ORDER BY COUNT (POPDATA.CITYNUM) DESC;
    
     
    shabbir likes this.

Share This Page

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice