Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Rhinorhino on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Having trouble with a report.

Status
Not open for further replies.

jwdcfdeveloper

Programmer
Joined
Mar 20, 2001
Messages
170
Location
US
I have a report that takes the results of three queries and determines percentages based on those queries. The first query gets the total number of participants in a given group. Here is the query:

select count(m.member_Id) AS BTP
from mem m, prepro pp, gro g
where m.member_id = pp.member_id
and pp.group_id = g.group_id
and g.category = 2
and m.status = 1
and g.name = 'Business Technology'
group by m.member_id

The second is a query is a query of a query. I needed it to get the total to remain in line with total from search results in another part of the application:

select count(BTP) AS BT2
from QueryName

The final query gets the number of members in each state:

select count(m.member_Id) AS BTCnt, s_name
from mem m, prepro pp, gro g, stat s
where m.member_id = pp.member_id
and m.state_fk = s.abbr
and pp.group_id = g.group_id
and g.category = 2
and m.status = 1
and state_name != '-- --'
and g.name = 'Business Technology'
Group BY s.s_name
Order by S_name

The problem I am having is that the second query totals 8400+ members, the third query totals over 12000 members. Therefore, the percentages of all the staes are almost always over 100 percent. I have tried substituting one query for another, I have tried making the queries look the same. Both attempted solutions only messed up the data that is correct. What do I need to do to get these percentages to work correctly?
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top