Super simplified code:
SELECT lots_of_stuff.
, A.more_stuff
, B.stuff
, C.things
FROM
table A,
table B,
table C,
where (B.more_stuff = A.stuff)
and things and stuff
and lots more things
and this query has so much crap believe me
and finally
and count(select c.things from table C where c.things like 'CRED')
> count(select c.things from table C where c.things like 'PUR')
;
So the problem is that that last bit does not work (and I'm certain I am doing it wrong entirely, this was just one guess on how to do it.) I was wondering if someone could give me some suggestions.
What I am trying to do is only return the desired fields for cases in which the number of rows containing 'CRED' in a particular field are greater than the number of rows containing 'PUR' in a particular field. (The same field, if that can simplify things.) I would like them to be returned regardless of if 'CRED' or 'PUR' are part of longer words (credit/purchase) or stand alone. They will always be all caps though.
Edit:
What I'm looking for is just those columns I specified
| More_Stuff | Stuff | Things |
| dshsdh | dfh | tjra |
| ddh | ash | ytra |
| shsdh | fgh | sayh |
| hsdh | gnh | tshn |
but only the rows for the customers that have more credit codes than purchase plans. So if they have 3 different entries in 'c.things' with something like "PHONE-CREDIT" or "OFFSET CRED." and 2 different entries in 'c.things' with something like "12 M PURCH PLAN" or "PROMO PURCHASE 36", I want their info to show up. So, when the number of rows with any credit codes is greater than the number of rows with any purchase plans. My current non-simplified query is already set to sort through all customers, I just need to specify which ones based on this filter.