Jump to content

SELECT with COUNTS and HAVINGS problems!


schone

Recommended Posts

Hi All!

Here is some initial info:

Table reports_interventions has:

- id
- date
- player_id
- qu_id
- value

[b]What I'm trying to do is:[/b]

Select all the player_id's who have the the same qu_id three times or more.

[i]For example[/i]

date = 2006-05-20
player_id = 5
qu_id = 3
value = 4

date = 2006-05-21
player_id = 5
qu_id = 3
value = 3

date = 2006-05-22
player_id = 5
qu_id = 3
value = 7

[b]What I have currently is:[/b]

[code]
SELECT COUNT( qu_id ) , player_id
FROM reports_interventions
GROUP BY player_id, qu_id
HAVING COUNT( qu_id ) >3
[/code]

The problem is that it selects all qu_ids and counts them.
What I want it to do is [b]select all qu_ids[/b] which are [b]the same[/b] which [b]occur 3 times or more[/b] for a [b]certain player_id.[/b]

Please Help!!!
Thanks to All!
:)
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.