Jump to content

oracle db how to get unique item per user

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"
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?

Link to post
Share on other sites


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.