We help IT Professionals succeed at work.
Get Started

Find % in query

Mike Eghtebas
Last Modified: 2014-05-10
The attached image shows the following query with data:
SELECT m.YYYY, m.LastYearCount, m.CurrYearCount, m.[01], m.[02], m.[03], m.[04], m.[05], m.[06], m.[07], m.[08], m.[09], m.[10], m.[11], m.[12], m.MedCtr_ID, m.StatType_ID
FROM tMonthlyMedCenter m
WHERE (((m.YYYY)=fnYYYY()) AND ((m.MedCtr_ID)=2) AND ((m.StatType_ID)=14 Or (m.StatType_ID)=15));

Open in new window

Currently, there are two rows filtered by StatType 14, and 15. This query needs to find % for each column and turn it to a single row showing % values from [01], [02],...[12] using:

Percent_01: ([01] StatType15) / ([01] StatType14)

There StatTypes other than 14 and 15. In some other question, I will expand the scope to see how far it could go.

Question: How can this calculation could be done with a single query?

Because performance is of a concern, I am open to another way of doing this also (for instance storing some of the rows in tem table or using VBA to do it).

Thank you.
Watch Question
EE Topic Advisor
Most Valuable Expert 2014
Awarded 2013
This problem has been solved!
Unlock 1 Answer and 5 Comments.
See Answer
Why Experts Exchange?

Experts Exchange always has the answer, or at the least points me in the correct direction! It is like having another employee that is extremely experienced.

Jim Murphy
Programmer at Smart IT Solutions

When asked, what has been your best career decision?

Deciding to stick with EE.

Mohamed Asif
Technical Department Head

Being involved with EE helped me to grow personally and professionally.

Carl Webster
CTP, Sr Infrastructure Consultant
Ask ANY Question

Connect with Certified Experts to gain insight and support on specific technology challenges including:

  • Troubleshooting
  • Research
  • Professional Opinions
Did You Know?

We've partnered with two important charities to provide clean water and computer science education to those who need it most. READ MORE