help on select count statement [message #370725] |
Sun, 23 January 2000 00:19 ![Go to next message Go to next message](/forum/theme/orafaq/images/down.png) |
judy brown
Messages: 1 Registered: January 2000
|
Junior Member |
|
|
have a table called ade_pole with column names of contact_01,contact_02,contact_03 and contact_04. the contacts are utility attachments that = 1phone,2phoneguy,3cable,4cableguy. how do i create statement that will tell me the number of phone attachments,phone with guys,phone with cable,cable attachement,cable w/guys, and cable or phone with cable/guy and phonew/guys? the numbers 1 thru 4 could be in any of contact_01 thru contact_04 columns.
thanks for your help.
|
|
|
Re: help on select count statement [message #370726 is a reply to message #370725] |
Sun, 23 January 2000 07:26 ![Go to previous message Go to previous message](/forum/theme/orafaq/images/up.png) |
Paul
Messages: 164 Registered: April 1999
|
Senior Member |
|
|
Judy,
This may point you in the right direction:
SELECT count (*),
'PHONE ' as CONTACT
FROM ade_pole
WHERE contact_01 = '1phone'
OR contact_02 = '1phone'
OR contact_03 = '1phone'
OR contact_04 = '1phone'
UNION
SELECT count (*),
'PHONE GUY' as CONTACT
FROM ade_pole
WHERE contact_01 = '2phoneguy'
OR contact_02 = '2phoneguy'
OR contact_03 = '2phoneguy'
OR contact_04 = '2phoneguy'
UNION
SELECT count (*),
'CABLE ' as CONTACT
FROM ade_pole
WHERE contact_01 = '3cable'
OR contact_02 = '3cable'
OR contact_03 = '3cable'
OR contact_04 = '3cable'
UNION
SELECT count (*),
'CABLE GUY' as CONTACT
FROM ade_pole
WHERE contact_01 = '4cableguy'
OR contact_02 = '4cableguy'
OR contact_03 = '4cableguy'
OR contact_04 = '4cableguy'
UNION
SELECT count (*),
'PHONE AND CABLE' as CONTACT
FROM ade_pole
WHERE ( contact_01 = '1phone'
OR contact_02 = '1phone'
OR contact_03 = '1phone'
OR contact_04 = '1phone'
)
AND ( contact_01 = '3cable'
OR contact_02 = '3cable'
OR contact_03 = '3cable'
OR contact_04 = '3cable'
);
Hope it helps,
Paul
|
|
|