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