Trying to expand a query here

Juan Pablo González

MrExcel MVP
Joined
Feb 8, 2002
Messages
11,959
Hey guys,

I'm trying to expand the functionality of the 'View unanswered posts' query, so it can show more unanswered posts than only those that have 0 replies.

My idea is this, look for all the topics that have > 0 replies, and in those, see if all the posters are the same (which would mean "bumps" by the OP).

I think I'm on the right track with this:

Code:
SELECT t.topic_id FROM topics t, posts p WHERE t.topic_id = p.topic_id AND t.topic_replies > 0 GROUP BY t.topic_id, p.poster_id

but what I need is to SELECT from this "intermediate" results, only those records in which t.topic_id appears ONCE.

Any ideas how to do that ?

So what I *think* I need is something like

Code:
SELECT * FROM (SELECT t.topic_id FROM topics t, posts p WHERE t.topic_id = p.topic_id AND t.topic_replies > 0 GROUP BY t.topic_id, p.poster_id) WHERE COUNT(topic_id) = 1

But it's not working (or it would be up and running now !!!)
 

Excel Facts

Pivot Table Drill Down
Double-click any number in a pivot table to create a new report showing all detail rows that make up that number
Ok, I think I got it:

Code:
SELECT t.topic_id, SUM(p.poster_id) sum1, SUM(t.topic_poster) sum2, COUNT(t.topic_id) total FROM topics t, posts p WHERE t.topic_id = p.topic_id AND t.topic_replies > 0 GROUP BY t.topic_id HAVING sum1/total = sum2/total

Kind of an ugly work-around, but hey, if it works, I'm happy !
 
Upvote 0

Forum statistics

Threads
1,215,438
Messages
6,124,873
Members
449,192
Latest member
MoonDancer

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top