Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8378705
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T15:59:18+00:00 2026-06-09T15:59:18+00:00

This is likely very easy, I haven’t used sql in a while and have

  • 0

This is likely very easy, I haven’t used sql in a while and have run into this problem. Basically, as part of a larger statement I only want to return a row from a select statement if a count from an inner select statement is equal to 3. How do I do that?

For example…

select rev.name, s.title 
from reviewer rev, song s, rating r 
where (r.rID = rev.rID) and (r.mID = s.sID) and ...[rest goes here];

Where the ‘rest’ is that I only want to return when reviewer rev has reviewed song s twice, and r.value was larger the first time (we denote first time as the one with the oldest r.date_of_rating.

This is clearly a count and compare, but I don’t know how to lay it out in proper SQL syntax. Any help would be greatly appreciated. Thanks

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-09T15:59:19+00:00Added an answer on June 9, 2026 at 3:59 pm

    I’m not sure your example gives enough info.

    But it sounds like you need a ‘HAVING’ clause.

    e.g.

    SELECT rev.name, s.title, count(r.mId)
    FROM reviewer rev, song s, rating r 
    WHERE (r.rID = rev.rID) AND (r.mID = s.sID) 
    GROUP BY rev.name, s.title
    HAVING count(r.mId) = 3
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

This very likely a setup issue on my part. I am trying to run
I've been stuck on this likely very simple problem, but haven't gotten anywhere with
So, interesting problem I've run into. I'm sure there's an easy solution, but I'm
this is most likely very easy but i'm struggling $(window).bind(load resize, function(){ var wH
This is likely very trivial but I haven't been able to figure it out.
This is likely a much broader SQL topic than Entity Framework, and I'm very
I feel bad because it is very likely this has already been answered and
Since in log4j javadoc is WARNING: This version of JDBCAppender is very likely to
This is most likely not an easy one but here is the situation: I
,This question is likely subjective, but a lot of grid Javascript plugins have come

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.