• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

sql query issue

 
swapnil kataria
Ranch Hand
Posts: 64
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
SELECT LOG_ID FROM LOG_TABLE
WHERE LOG_ID = 261 ORDER BY MODIFIED_DATE

-- a LOG_ID can have multiple record with different MODIFIED_DATE
suppose it will give follwing result

log_id
---------------
261
262
267
323
261

in this 261 is coming twice, but i want it only single time,
if i apply DISTINCT then i have to write like this

SELECT LOG_ID, MODIFIED_DATE FROM LOG_TABLE
WHERE LOG_ID = 261 ORDER BY MODIFIED_DATE

but it will also show duplicate records,
i can understand distinct will not work bcz 261 has two different record with different dates,
but don't want to pick same record second time, means only one record should come in result, but order should be maintained

please help
 
Darryl Burke
Bartender
Posts: 5126
11
Java Netbeans IDE Opera
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
 
swapnil kataria
Ranch Hand
Posts: 64
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
ohmm, i have written, it should be order by modified date,
any way i have done it
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic