How to get percentage and sort

Y

Yubasus

Hello,

I am hopping someone will help me with this.

I have three columns in my query LakeID, GR5, AREA. The LakeID is a number
that identifies a lake. Within that lake there are (GR5) 5 levels of chemical
substances that can be found going from 0 to 5. The AREA is identified as the
amount of total area that a certain chemical can be found in.

What I would like to do is query the data so that it gives me the GR5 rating
going from the highest number of area that a GR5 covers to the lowest. Also,
I want the query to show what the percentage for each GR5 is of the total
area of the lake.

This is what I have so far.

SELECT adamhdwtrgeo.LAKE_ID, Sum(adamhdwtrgeo.AREA) AS SumOfAREA,
adamhdwtrgeo.GR5
FROM adamhdwtrgeo
GROUP BY adamhdwtrgeo.LAKE_ID, adamhdwtrgeo.GR5
ORDER BY adamhdwtrgeo.LAKE_ID, Sum(adamhdwtrgeo.AREA);
 
M

Michel Walsh

Hi,




SELECT a.id, a.gr5
SUM(a.x),
SUM(a.x) / (SELECT SUM(b.x)
FROM myTable As b
WHERE b.id=a.id )

FROM myTable As a

GROUP BY a.id, a.gr5
ORDER BY a.id, SUM(a.x)




Hoping it may help,
Vanderghast, Access MVP
 
Y

Yubasus

Thanks.

I tried the query and it gives me an error message that reads Syntax error
(missing operator) in query expression 'a.gr5 SUM(a.x)'.

Another question, would I replace the query you suggested witht the one I
have or add it?

As you can see I have not done many before. So, anything you can do to help
me will be really appreciated.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top