944,196 Members | Top Members by Rank

Ad:
Jul 12th, 2006
0

Select Problem of COUNT on GROUP

Expand Post »
hi, i am a user of Toad for Oracle 8.6.1
i am having a problem contructing this query

SELECT
FAC.FACILITY_ABBR hall_abbr,
COUNT(HALLUNIT.ACCEPTS_MALES_FLAG) MISDEMEANOR_MALE,
COUNT(HALLUNIT.ACCEPTS_FEMALES_FLAG) MISDEMEANOR_FEMALES
FROM
HALL_UNITS HALLUNIT,
FACILITIES FAC
WHERE
HALLUNIT.HALL_ID = FAC.ID
AND
HALLUNIT.ACCEPTS_MALES_FLAG ='T'
AND HALLUNIT.ACCEPTS_FEMALES_FLAG ='T'GROUPBY
FAC.FACILITY_ABBR

the result is:

hall_abbr MISDEMEANOR_MALE MISDEMEANOR_FEMALES
BJNJH 1 1
CJH 2 2
LPJH 2 2

that suppose to be:

hall_abbr MISDEMEANOR_MALE MISDEMEANOR_FEMALES
BJNJH 1 3
CJH 2 3
LPJH 2 3

its copies the result of MISDEMEANOR_MALE to MISDEMEANOR_FEMALES.. and i cant figure out why..

please help me...

thanks
Similar Threads
Reputation Points: 10
Solved Threads: 0
Newbie Poster
Jerrymie is offline Offline
1 posts
since Jul 2006
Jul 12th, 2006
0

Re: Select Problem of COUNT on GROUP

This is a logic error you are asking where MALE AND FEMALE = 'T'

By definition that filters out any records where MALE <> 'T' OR FEMALE <> 'T'

try this, let me know if it works
SELECT
FAC.FACILITY_ABBR hall_abbr,
COUNT(HALLUNIT.ACCEPTS_MALES_FLAG) MISDEMEANOR_MALE,
COUNT(HALLUNIT.ACCEPTS_FEMALES_FLAG) MISDEMEANOR_FEMALES
FROM
HALL_UNITS HALLUNIT,
FACILITIES FAC
WHERE
HALLUNIT.HALL_ID = FAC.ID
AND HALLUNIT.ACCEPTS_MALES_FLAG ='T'
OR
HALLUNIT.HALL_ID = FAC.ID
AND HALLUNIT.ACCEPTS_FEMALES_FLAG ='T'
Last edited by hollystyles; Jul 12th, 2006 at 10:55 am.
Reputation Points: 262
Solved Threads: 68
Veteran Poster
hollystyles is offline Offline
1,181 posts
since Feb 2005

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in IT Professionals' Lounge Forum Timeline: Cool Games and Source Code
Next Thread in IT Professionals' Lounge Forum Timeline: can anyone help me out...





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC