Skip to Main Content

SQL & PL/SQL

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

issue with counting and multiple columns

513466Jun 15 2006 — edited Jun 15 2006
OK, so I have three tables, and I'll give some sample info:

SMS_DATA.PATCH_STATUS

computername bulletinid os service_pack
D12345 MS01 WXP SP2
D12345 MS02 WXP SP2
D12345 MS03 WXP SP2
D12345 MS04 WXP SP2
L2345 MS01 W2K SP4
L2345 MS03 W2K SP4

SMS_DATA.GET_ASSOCIATES_MV

computername managed_by supported_by owned_by
D12345 John Smith IT Services Accounting
L2345 Mary Jones Process Automation Operating Services

ARADMIN.AST_CONFIGURATION_ITEM__CI_

name tag_number deploy__type ci__status
D12345 12345 auto in service
L2345 2345 manual retired

Ok, so what i want as a result, is a report looking something like this:

Computer Missing Patches Manager Supporter Owner Deploy Status
D12345 4 John Smith IT Services Accounting auto in service
L2345 2 Mary Jones P.A. O.S. manual retired

Basically, the purpose of this is to find a summary of the top 10 unpatched computers, and although the computer name is a link to a page with further details, the users would like the other fields in the table for a quick descriptive of the computer's whereabouts.

However, I'm having some issues with my query:

SELECT ps.computername, count(ps.bulletinid), ps.os, ps.service_pack, mv.managed_by, mv.owned_by, mv.supported_by
FROM sms_data.patch_status ps, aradmin.ast_configuration_item__ci_ aci
LEFT JOIN aradmin.get_associates_mv mv
ON mv.computername = ps.computername
WHERE (ps.bulletinid != 'None') and
(aci.name = ps.computername) and
(aci.ci_status <= 5)
GROUP BY ps.computername
ORDER BY 2 desc

is giving me the error:

1 error has occurred
Query cannot be parsed within the Builder. If you believe your query is syntactically correct, check the ''generic columns'' checkbox below the region source to proceed without parsing. ORA-00904: "PS"."COMPUTERNAME": invalid identifier

if I try to make it simpler,

SELECT ps.computername, count(ps.bulletinid), ps.os, ps.service_pack, mv.managed_by, mv.owned_by, mv.supported_by
FROM sms_data.patch_status ps, aradmin.ast_configuration_item__ci_ aci, sms_data.get_associates_mv mv
WHERE (mv.computername = ps.computername) and
(ps.bulletinid != 'None') and
(aci.name = ps.computername) and
(aci.ci_status <= 5)
GROUP BY ps.computername
ORDER BY 2 desc

I get the error:

ORA-0937 - Not a single-group group function

It's the count that's messing me up... if I just displayed the bulletinid's individually, it works fine, it doesn't like me trying to sum them (when I also want the additional fields). It seems like I have two options:

a) just have the computer name and count of missing patches, with no additional info
b) just have the computer info and individual patches, which defeats the purpose of a top 10

I'm wondering if anyone has had to do anything similar (combine a count of one column with other columns on the row), and if they could share their solution.

Thanks,
Catherine
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Jul 13 2006
Added on Jun 15 2006
6 comments
535 views