Jump to content

[SOLVED] grouping problem


pluginbaby

Recommended Posts

hi

 

I want to select the record out of a table with the highest time (MAX(time)) and I want to get the username from that record. This should only be records where ctId=0.

 

I first tried:

 

SELECT MAX(time),username FROM table WHERE ctId=0

 

but that gave me a grouping error  :-[

then I did some research about groups and stuff, since I didn't know that much about them, and I tried:

 

SELECT max(time),username,ctId FROM table GROUP BY username,ctId HAVING ctId=0 AND MAX(time)

 

But that gives me not the record with the highest time...   :-\

You have any idea what I am doing wrong?

 

Thank you in advance

 

edit: I made a typo in the code  ;D

Link to comment
https://forums.phpfreaks.com/topic/58853-solved-grouping-problem/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.