0

I have maybe a dumb question? Anyways, I can't figure it out.

blah blah
GROUP BY cp.c, cp.r
HAVING COUNT(*) = (SELECT COUNT(cp.r)
                  FROM cp
                  WHERE cp.r IN (SELECT cr.r
                                 FROM cr
                                  WHERE cr.r LIKE '%blah&'));

SELECT cr.r has multiple values and it works alright

The problem is in HAVING COUNT(*) = (SELECT COUNT(cp.r)) Can I even do that?

So far the query returns nothing which should not happen according to the data.

user963070
  • 629
  • 2
  • 19
  • 24
  • This is valid as far as I know. Make a fiddle with some sample data demonstrating the problem. – Barmar Sep 29 '13 at 21:22
  • I am trying to select the rows where count (COUNT(*)) (the total rows of the same group) equals the amount of (SELECT COUNT) of different rows that match a description. – user963070 Sep 29 '13 at 22:05
  • 2
    I can see that, and I think it should work. Since you claim that it's not working, please post enough information so we can see the problem. – Barmar Sep 29 '13 at 22:06
  • http://hostcode.sourceforge.net/view/1036 I posted the code I'm working with there. Sorry about the spacing. Not sure how to fix that. Goal (ignoring part of it that I haven't coded yet): Write a single query that shows the community names that are in a central region. Anyways, each CommunityAreaNumber has multiple entries with varying types of regions. I hope my teacher doesn't mind me posting my solution online, but I'm really stuck. – user963070 Sep 29 '13 at 23:29
  • Where is the input data? The best way to provide this is by making a sqlfiddle. – Barmar Sep 29 '13 at 23:30
  • Also, please tag your question with the DBMS, since there may be differences between implementations (mysql, sql-server, Oracle, etc). – Barmar Sep 29 '13 at 23:31
  • Huh? Do what? The input data is thousands....but I do have an ERD http://www.thatlink.com/Classes/Main/DisplayImage.aspx?Section=cis2725fa13&File=ChicagoParksErd.png – user963070 Sep 29 '13 at 23:37
  • Just make a small sample. – Barmar Sep 29 '13 at 23:38
  • let us [continue this discussion in chat](http://chat.stackoverflow.com/rooms/38303/discussion-between-user963070-and-barmar) – user963070 Sep 29 '13 at 23:42

0 Answers0