1. Having "HAVING" problems with GROUP BY.
My query is quite complex, and it also not working properly! *g*
From 2 tables, I am selecting records grouped by player_id where a certain
number of conditions are met (ie: date_caught, etc.)
I need to perform 2 GROUP BYs. 1 to ensure that the SUM of the
actual_points is within a certain value, and the 2nd to ensure that each
player has at least 4 entries.
I am only choosing the top four, which isn't a problem for players with 4 or
more entries, but the group by is NOT working for players who have less than
4 entries. It is NOT leaving out the players with 3 or less
entries......ANY HELP WOULD BE GREATLY APPRECIATED.
Here's the SQL (i've tried to snip it as much as I could....):
SELECT player_id , ROUND(SUM(actual_points)) as points FROM ( SELECT * FROM
(SELECT player_id
, actual_points
, row_number() OVER (PARTITION BY player_id ORDER BY actual_points desc)
rank
, date_caught
FROM (SELECT *
FROM (SELECT ce.entry_id
, ce.date_caught as date_caught
, ce.actual_points as actual_points
, ce.player_id as player_id
FROM fantasy_entries ce )
UNION
SELECT *
FROM( SELECT ce.entry_id
, ce.date_caught as date_caught
, ce.actual_points as actual_points
, players.player_id as player_id
FROM catch_entries ce, dogfish.players
WHERE ce.pin = players.pin )
)
)
WHERE rank < 5
AND player_id IN ( SELECT *
FROM (SELECT player_id
FROM fantasy_entries
UNION
SELECT *
FROM (SELECT player_id
FROM (SELECT pl.player_id as player_id
, ce.pin
FROM players pl
, catch_entries ce
WHERE pl.pin = ce.pin)
)
)
GROUP BY player_id HAVING COUNT(actual_points) = 4) /*(when this is '> 0',
it works okay, it just doesn't filter the players with more than 4
entries)*/
)
GROUP BY player_id HAVING SUM(actual_points) BETWEEN 0 AND 2800
ORDER BY points desc
Thanks in advance....I really appreciate any insight. (I've been fighting
with this for a week!)
--
Joseph Ranseth - Webmaster
World Cup Fishing
http://www.worldcupfishing.com
2. HELP !!! Anyone who know how to extract CDX for VFP3
3. we r having this problem...can anybody help...
4. I need a FoxPro tutor in Barre, VT area.
5. ESQL problem...anyone else having problems with ESQL?
6. R83 DAT Drivers
7. I am having a problem with a hard disk drive or floppy disk drive
8. How to programmetically invoke SQL Query builder
9. SQLServer Performance : Still having problems
10. help!!! having problems upgrading 6.5 to 7.0
11. Attaching / Detaching in TRUE path having some problem.
12. Image storage and retrieval - still having problems!
13. Using SQL Server 1.1, EVC++, ADOCE 3.1 and having problems