wood burning stoves 2.0*
The moose likes JDBC and the fly likes Can We check Duplicates from String in a Query? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Databases » JDBC
Bookmark "Can We check Duplicates from String in a Query?" Watch "Can We check Duplicates from String in a Query?" New topic
Author

Can We check Duplicates from String in a Query?

Shahir Deo
Ranch Hand

Joined: Mar 19, 2013
Posts: 78

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.


Knowledge enlivens the soul.
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 41092
    
  44
I think a GROUP BY is needed on the string attribute, and then a MAX on the datetime attribute


Ping & DNS - my free Android networking tools app
Shahir Deo
Ranch Hand

Joined: Mar 19, 2013
Posts: 78

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
Marshal

Joined: Mar 22, 2005
Posts: 41092
    
  44
Well, that's a complication that was not mentioned in your original post. What should the result be in that case?
Jeanne Boyarsky
internet detective
Marshal

Joined: May 26, 2003
Posts: 30085
    
149

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.


[Blog] [JavaRanch FAQ] [How To Ask Questions The Smart Way] [Book Promos]
Blogging on Certs: SCEA Part 1, Part 2 & 3, Core Spring 3, OCAJP, OCPJP beta, TOGAF part 1 and part 2
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Can We check Duplicates from String in a Query?
 
Similar Threads
Oracle - Retriving only latest data from a table if there is a Duplicate.
Help in Query
Urgent Help in Query
Struts 2 Multiple Input problem
Oracle - Retriving only latest data from a table if there is a Duplicate.