Sie sind auf Seite 1von 9

All Places > Developer > English > Oracle Database > SQL and PL/SQL > Discussions

THIS DISCUSSION IS ARCHIVED

13 Replies Latest reply: Sep 17, 2008 11:31 PM by 337410

602082 Nov 28, 2007 10:24 AM

How to find duplicate records in a table


Hi, I have a table named JE_DESC. The fields it in it are JE_NUMBER,MONTH,ENTITY_REFERENCE and AMOUNT.

I want to find duplicate records with JE_NUMBER,MONTH and ENTITY_REFERENCE combination. Then i want to find the Sum of Amount in the duplicate fields Can anyone help me in generating a query for this Thanks in advance

7783 Views

597312 Nov 28, 2007 10:33 AM (in response to 602082) 1. Re: How to find duplicate records in a table S Q L > S E L E C T* F R O MJ E _ D E S C

W H E R ER O W I DN O TI N( S E L E C TM I N ( R O W I D )F R O MJ E _ D E S C G R O U PB YJ E _ N U M B E R ) ; try it out not tested...

Like (0)

608922 Nov 28, 2007 10:39 AM (in response to 602082) 2. Re: How to find duplicate records in a table

S E L E C TS U M ( A M O U N T )F R O MJ E _ D E S CG R O U PB YJ E _ N U M B E R , M O N T H , E N T I T Y _ R E F E R E N C E

Like (0)

606834 Nov 28, 2007 10:44 AM (in response to 602082) 3. Re: How to find duplicate records in a table To find find duplicate records with JE_NUMBER,MONTH and ENTITY_REFERENCE combination use select JE_NUMBER,MONTH,ENTITY_REFERENCE, count(1) from JE_DESC group by JE_NUMBER,MONTH,ENTITY_REFERENCE having count(1) > 1

Like (0)

602082 Nov 28, 2007 11:25 AM (in response to 606834) 4. Re: How to find duplicate records in a table

can u please expain count(1)>1

Like (0)

WhiteHat Nov 28, 2007 11:28 AM (in response to 602082) 5. Re: How to find duplicate records in a table count(*) or count(rownum) would work exactly the same way, it just has to have a value to count.

Like (0)

602082 Nov 28, 2007 12:17 PM (in response to WhiteHat) 6. Re: How to find duplicate records in a table Also i want to check a condition whether Sum of amount is 0 and Entity reference is null in the grouping..How can i do it?

Like (0)

612530 Dec 22, 2007 5:45 AM (in response to 602082) 7. Re: How to find duplicate records in a table Hi check whther this fits ur requirement( not tested) SELECT je_number, MONTH, DECODE(ENTITY_REFERENCE,null,'its null' ENTITY_REFERENCE), DECODE(SUM(amount),0, 'ITS ZERO', SUM(AMOUNT))

FROM JE_DESC GROUP BY JE_NUMBER, MONTH HAVING COUNT(1)>1 correct me if i'm wrong Thank u

Like (0)

648359 Sep 15, 2008 9:35 AM (in response to 602082) 8. How to get the record which contains single quote in APEX Hi All, I am having one table which contains the name like D'ales,D'silva. I have have one filter in APEX as "Name". I need to filter it like D' % this . How can i do in apex, the replace command is working in SQL but not in Apex. My filter is like this. IF :P136_NAME IS NOT NULL THEN STR := STR||' AND UPPER( replace(name,'''','''''')) LIKE '''||UPPER(:P136_NAME)||''' '; END IF;

very urgernt Thanks in Advance,

Like (0)

337410 Sep 16, 2008 1:27 AM (in response to 648359) 9. Re: How to get the record which contains single quote in APEX Hi, Try something like this. S Q L >s e l e c t' T r u e ' 2 f r o md u a l 3 w h e r e' d ' ' s i l v a 'l i k e' d ' ' % ' 4 / ' T R U E ' T r u e a friendly reminder :) Don't reply to an old thread to start a new different topic. Don't use Urgent or ASAP in your post. Cheers.

Like (0)

648359 Sep 17, 2008 4:00 AM (in response to 337410) 10. Re: How to get the record which contains single quote in APEX Hi, The simple thing what you explained in working in sql and plsql, that is not a problem, This is NOT WORKING IN APEX. when we are filtering.

Like (0)

337410 Sep 17, 2008 4:27 AM (in response to 648359) 11. Re: How to get the record which contains single quote in APEX

user645356 wrote: This is NOT WORKING IN APEX. when we are filtering. Post what is the error. (e.g. Did it return 0 rows, etc. ) is your column being compared varchar2 or char? are they all capital letters? hmm, I used Apex online (apex.oracle.com) to test, it ran correctly. Ok how about this (it also ran correctly on apex online). w i t hta s-" s a m p l ed a t a " ( s e l e c t' d ' ' s i l v a 'n a m e _f r o md u a lu n i o na l l s e l e c t' j o h n 'n a m e _f r o md u a lu n i o na l l s e l e c t' d ' ' a b o 'n a m e _f r o md u a l )-" e n ds a m p l ed a t a " s e l e c tn a m e _ f r o mt w h e r en a m e _l i k e' d ' | | c h r ( 3 9 ) | | ' % ' You may also want to read about regexp_like.

Like (0)

648359 Sep 17, 2008 8:44 AM (in response to 337410)

12. Re: How to get the record which contains single quote in APEX Hi

I have a text like this d'skjdlkjkd, a'kjkjd. I can able to find in plsql using double quote like d''skdlkjd, But how can i do in apex? select name from <table> where name like (d''skjdlkjkd) is possible in plsql. select name from <table> where name like (d'skjdlkjkd) is it possible? I want to replace this(') with (''), is there any idea in apex? I searched in reg_exp also.

Like (0)

337410 Sep 17, 2008 11:31 PM (in response to 648359) 13. Re: How to get the record which contains single quote in APEX Hi,

Assuming that you are connecting ( APEX and sql*plus) to the same DB version the query will run in both. The only time it won't run is if APEX and sql*plus connect to different versions and you use commands that are version specific like regexp_count for 11g, other regular expressions for 10g/11g. In your case chr(39) is equal to apostrophe (')

here are examples on its use

S Q L >w i t hta s-" s a m p l ed a t a " 2 ( s e l e c t' d ' ' s i l v a 'n a m e _f r o md u a lu n i o na l l 3 s e l e c t' j o h n 'n a m e _f r o md u a lu n i o na l l 4 s e l e c t' d ' ' a b o 'n a m e _f r o md u a lu n i o na l l 5 s e l e c t' a ' ' a b o 'n a m e _f r o md u a l 6 )-" e n ds a m p l ed a t a " 7 s e l e c tn a m e _ 8 f r o mt 9 w h e r en a m e _l i k e' d ' | | c h r ( 3 9 ) | | ' % ' -e q u a lt ol o o kf o rr o w st h a ts t a r tw i t hda n da na p o s t r o p h e 1 0 / N A M E _ d ' s i l v a d ' a b o

S Q L > S Q L >w i t hta s-" s a m p l ed a t a " 2 ( s e l e c t' d ' ' s i l v a 'n a m e _f r o md u a lu n i o na l l 3 s e l e c t' j o h n 'n a m e _f r o md u a lu n i o na l l 4 s e l e c t' d ' ' a b o 'n a m e _f r o md u a lu n i o na l l 5 s e l e c t' a ' ' a b o 'n a m e _f r o md u a l 6 )-" e n ds a m p l ed a t a " 7 s e l e c tn a m e _ 8 f r o mt 9 w h e r en a m e _l i k e' % ' | | c h r ( 3 9 ) | | ' % '-e q u a lt ol o o kf o rr o w st h a th a sa na p o s t r o p h e( ' )a n y w h e r ei 1 0 / N A M E _ d ' s i l v a d ' a b o a ' a b o

S Q L > S Q L >w i t hta s-" s a m p l ed a t a " 2 ( s e l e c t' d ' ' s i l v a 'n a m e _f r o md u a lu n i o na l l 3 s e l e c t' j o h n 'n a m e _f r o md u a lu n i o na l l 4 s e l e c t' d ' ' a b o 'n a m e _f r o md u a lu n i o na l l 5 s e l e c t' x x ' ' a b o 'n a m e _f r o md u a lu n i o na l l 6 s e l e c t' a ' ' a b o 'n a m e _f r o md u a l 7 )-" e n ds a m p l ed a t a " 8 s e l e c tn a m e _ 9 f r o mt 1 0 w h e r en a m e _l i k e' _ ' | | c h r ( 3 9 ) | | ' % '-e q u a lt ol o o kf o rr o w sw h e r e2 n dc h a r a c t e ri sa na p o s t r o p h e 1 1 / N A M E _ d ' s i l v a d ' a b o a ' a b o

Like (0)

About Oracle | Oracle and Sun |

| Subscribe | Careers | Contact Us | Site Maps | Legal Notices | Terms of Use | Your Privacy Rights | Cookie Preferences

Das könnte Ihnen auch gefallen