Hello,
I need to get all records from a table where a for a given playerid no
field enddate exists with value NULL.
table player_team:
id, playerid, startdate, enddate
1, 277, 2003-09-14 00:00:00, NULL
2, 278, 2003-09-14 00:00:00, NULL
3, 279, 2003-09-14 00:00:00, NULL
4, 280, 2003-09-14 00:00:00, NULL
5, 281, 2003-09-14 00:00:00, 2004-03-11 17:30:00
6, 282, 2003-09-14 00:00:00, 2004-03-11 17:30:00
7, 281, 2004-03-11 18:03:45, NULL
8, 282, 2004-03-12 12:58:13, 2004-03-12 13:02:00
9, 282, 2004-03-12 13:02:55, 2004-03-12 13:07:20
So the records where the enddate is not NULL are
id=5, playerid=281
id=6, playerid=282
id=8, playerid=282
id=9, playerid=282
I only want to get playerid 282 back because there exists no record
with this playerid where enddate is NULL
So it must be something like this:
SELECT
playerid
FROM
speler_team
WHERE
COUNT(enddate IS NULL)=0
GROUP BY
spelerid
This does not work. It comes up with an "Invalid use of group
function" error. How to do this?
Thanks for your help,
I need to get all records from a table where a for a given playerid no
field enddate exists with value NULL.
table player_team:
id, playerid, startdate, enddate
1, 277, 2003-09-14 00:00:00, NULL
2, 278, 2003-09-14 00:00:00, NULL
3, 279, 2003-09-14 00:00:00, NULL
4, 280, 2003-09-14 00:00:00, NULL
5, 281, 2003-09-14 00:00:00, 2004-03-11 17:30:00
6, 282, 2003-09-14 00:00:00, 2004-03-11 17:30:00
7, 281, 2004-03-11 18:03:45, NULL
8, 282, 2004-03-12 12:58:13, 2004-03-12 13:02:00
9, 282, 2004-03-12 13:02:55, 2004-03-12 13:07:20
So the records where the enddate is not NULL are
id=5, playerid=281
id=6, playerid=282
id=8, playerid=282
id=9, playerid=282
I only want to get playerid 282 back because there exists no record
with this playerid where enddate is NULL
So it must be something like this:
SELECT
playerid
FROM
speler_team
WHERE
COUNT(enddate IS NULL)=0
GROUP BY
spelerid
This does not work. It comes up with an "Invalid use of group
function" error. How to do this?
Thanks for your help,
Comment