Jump to content

Recommended Posts

Hi, I have a problem whereby I need to produce "only" one item per user e.g

it's a portal that has many users and they can post alot of items, regardless whether it's a registered or non registered user.

can someone give me a pseudo thing that may help solve this sql statement problem?

or atleast an sql code snippet..

 

if I do this

 

select userid, itemtitle, max(itemid) as ad from itemtable where status = 1
and expirydate > current_date and publishdate is not null and displaypublishdate is not null 
group by userid order by displaypublishdate desc;

it throws an error in my sql developer

 

 

ORA-00979: not a GROUP BY expression
00979. 00000 -  "not a GROUP BY expression"
*Cause:    
*Action:
Error at Line: 33 Column: 15

it only produces results when i changed the "order by" into 

order by ad 

and removed the itemtitle among the selected columns

 

but I need to order it by displayplublishdate or publishdate in descending order..and also

I need to get the item title as well...because I need to display the item title in the front-end of the portal

 

so how?

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.