• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Can We check Duplicates from String in a Query?

 
Shahir Deo
Ranch Hand
Posts: 80
Hibernate Java Oracle
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Guys ,


I am using Oracle Db

I have a table which consists of Value , start date and End Date columns

Table Data:

1.I have "two" pie in my Bag----12/2/13
2.I have "three" pie in my Bag----13/2/11
3.I have "two" pie in my Bag--8/1/09
4.I have "five" pie in my Bag--7/11/10


I want to display Sr. 1, 2 and 4

Sr.3 consists "two" and date is past compare to new "two"(sr.1) , so it should not be displayed.

Please Help

Thanks.
 
Ulf Dittmer
Rancher
Posts: 42968
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I think a GROUP BY is needed on the string attribute, and then a MAX on the datetime attribute
 
Shahir Deo
Ranch Hand
Posts: 80
Hibernate Java Oracle
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
But what if String is Different.

Like :

Table Data:

1.I have "two" pie in my Bag----12/2/13
2.I have "three" pie in my Bag----13/2/11
3.I have "two" pie in my Bag--8/1/09
4.I have "five" pie in my Bag--7/11/10
5.No You dont have "two" pie--14/5/09
 
Ulf Dittmer
Rancher
Posts: 42968
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Well, that's a complication that was not mentioned in your original post. What should the result be in that case?
 
Jeanne Boyarsky
author & internet detective
Marshal
Posts: 34695
367
Eclipse IDE Java VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You might need to add Oracle regular expressions to the query. That way you can restrict a column/group by to the particular part you are interested in checking for duplicates.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic