Query database fields are the same character but not in the same order

Hello Oracle WIZ !
I have a simple question regarding perhaps a function.
I have a columns in a database with data the could have been transpose meaning the keyer might have entered. 1234 and someone else could have come in and put 2134.
the characters are the same but the numbers are in a different order. Is there any function that would allow me to query just based on characters? hence bringing back the 1234 and 2134 rows?
Hope this makes sense
Thanks
all

Hi,
You can use CONNECT BY to re-arrange the characters in a string in ascending order, then use that value to compare strings.
For example, in the following sample data:
CREATE TABLE     table_x
AS
SELECT     1 AS id,     '1234' AS txt     FROM dual     UNION ALL
SELECT     2,          '4231'          FROM dual     UNION ALL
SELECT     3,          '433'          FROM dual     UNION ALL
SELECT     4,          '343'          FROM dual     UNION ALL
SELECT     5,          '431'          FROM dual     UNION ALL
SELECT     9,          NULL          FROM dual
;ids 1 and 2 both have txt consisting of '1', '2', '3' and '4'.
ids 4 and 5 both have txt consisting of '3', '3' and '4'.
There are no other matches.
This query finds those pairs:
WITH     cntr     AS
     SELECT     LEVEL     AS n
     FROM     dual
     CONNECT BY     LEVEL <= ( SELECT  MAX (LENGTH (txt))
                       FROM        table_x
,     got_ordered_txt     AS
     SELECT     x.id
     ,     x.txt
     ,     MIN (SYS_CONNECT_BY_PATH (SUBSTR (x.txt, c.n, 1), ','))     AS ordered_txt
     FROM     table_x     x
     JOIN     cntr     c     ON     c.n     <= LENGTH (x.txt)
     WHERE     LEVEL     = LENGTH (x.txt)
     CONNECT BY NOCYCLE     x.id     = PRIOR x.id
          AND          c.n     != PRIOR c.n
     GROUP BY     x.id
     ,          x.txt
SELECT     a.id
,     a.txt
,     b.txt
,     b.id
FROM     got_ordered_txt     a
JOIN     got_ordered_txt     b     ON     a.id          < b.id
                    AND     a.ordered_txt     = b.ordered_txt
;Output:
.       ID TXT  TXT          ID                                                
         3 433  343           4                                                
         1 1234 4231          2                                                

Similar Messages

  • I am trying to delete songs from itune 11 library and i want it to delete the song from my hard drive as well.  All my songs are in the music folder but not in the itunes folder??  itunes did not prompt me to move file to trash nor is there an option??

    I am trying to delete songs from itune 11 library and i want it to delete the song from my hard drive as well.  All my songs are in the music folder but not in the itunes folder.  itunes did not prompt me to move file to trash nor is there an option to remove file to trash bin.  How can i  delete songs from both the itunes and hard drive at the same time?

    aespinoza2210 wrote:
    could it be in the itunes folder or does it have to be in the itunes media folder, which is within the itunes folder??
    A Espinoza,
    The iTunes Media folder is set in Preferences > Advanced, and is the key to most iTunes folder organizational activities.  So I doubt that the automatic deletion will work for files that are somewhere else within the folder structure.
    However, I have not experimented with that issue in quite a while, so you are welcome to give it a try in iTunes 11. 

  • Suddenly all my albums in Photos are blank.  The photos are still in the camera roll but not in the albums.  What happened and how do I recover them all?  Are they in my icloud?  Also the photos are clear as thumprints but when I touch it to zoom are blur

    Suddenly all my albums in Photos are blank.  The photos are still in the camera roll but not in the albums.  What happened and how do I recover them all?  Are they in my icloud?  Also the photos are clear as thumprints but when I touch it to zoom are blurry.  what gives?  They were all completely clear and in the albums when I last used my ipad??  Would doing the "Reset" under General settings do that?  When I returned from Europe I reset my ipad to get it in the right time zone etc. 

    Reboot.   Press and hold the home and sleep buttons until the apple logo appears. Ignore the red slider.

  • I am using Adobe Reader X on a laptop with Windows Vista OS and Adobe Reader XI on an older laptop with Windows XP OS.  While filling out the same form on each computer, I have found that I can save info on the older laptop, but not on the newer one.  Thi

    I am using Adobe Reader X on a laptop with Windows Vista OS and Adobe Reader XI on an older laptop with Windows XP OS.  While filling out the same form on each computer, I have found that I can save info on the older laptop, but not on the newer one.  This is a big problem.  I must be able to save on the newer computer.  Do I need to buy a new computer with a more up-to-date OS?  Please help.

    Adobe Reader X can only save reader-enabled forms. Adobe Reader XI can save all forms.

  • Can Management Studio connect to a server that is on the same network but not on the same domain?

    Should management studio be able to connect to an instance of an sql server that is on the same network but not on the same domain?  I am trying to have it do so but am unsuccessful, so to continue to troubleshoot what the issue might be I need to know
    whether I am embarking on an exercise in futility.

    Hello,
    That's your issue!
    Since you're attempting to use Windows Authentication you'll need to start the SSMS process under the domain credentials of the domain account that has access to that SQL Server. Otherwise windows is going to send you local user token which is going to quickly
    be rejected as your local computer user account is not the correct domain account.
    You can do this by either using shift+right-click run as different user or from the command line using RunAs /user.
    In either case, if you want to use Windows Authentication you'll need to run the SSMS process as that domain user so that you can pass a valid security token.
    Edit:
    I read that backwards... If it's not on any domain (or member of a workgroup) you'll have a really hard time in using windows authentication as you're limited to LOCAL users on that machine. Thus you could really only use windows auth if you were logged
    in locally on that server. I'd either setup a SQL Login for this or join it to a domain.
    Sean Gallardy | Blog |
    Twitter

  • How do I get the Label for a Front Panel Control to appear in the Block Diagram but not on the Front Panel?

    How do I get the Label for a Front Panel Control to appear in the Block Diagram but not on the Front Panel? On the Front Panel I am making a complex control that consists of a Slider and a Numerical Input box. Both Controls display the same information and either can be used for Input. When one changs, the other is made to display the same value.
     But I only want the Slider to display the Label on the Front Panel, to avoid confusion. On the Block Diagram however, I want both controls to display their Labels so that I know what they are. How do I display the Label for a Control on the Block diagram, but not display its Label on the Front Panel?

    No.  The Label Visible property is separate for the front panel control label and the block diagram terminal label.
    How did you start out with the block diagram's label not being visible?  Whenever I drop a control or indicator, the label is always visible on both the FP and BD by default.  Maybe there is a LabVIEW option that causes new controls/indicators not to have their labels visible by default, but I have yet to find it.  I don't think an item should ever be dropped without the label visible, good LabVIEW coding practice demands that the labels for control terminals on the block diagram be visible so that you know what control or indicator a wire is going to.
    That being said, I have seen a lot of VI's posted where the label for the terminal on the BD is not shown (against good programming practice.)  I've gone to the BD and right clicked to show the label.  Sometimes, the people have an empty label (which will turn off the visibility for both the FP and BD) and I'm forced to add some text of my own into the label so I can figure out what their code is doing.  When I add some text to the label, at that time, I find both the BD and FP labels become visible.
    Are you dealing with controls that have empty labels to start?
    Good programming practices:
    1.  Always have a name for all of your controls, never use and empty label by deleting the text in the label.
    2.  Make the labels unique.  For example, don't have two controls both called Stop.  How do you know quickly know which terminal relates to which control?
    3.  Always show the labels on the block diagram, so you know the function of a control's terminal.  If you want to hide the label on the FP, that's okay.
    4.  If you want a different label to appear on the FP than whatever you actually called the control, then use the caption.  You can hide the label and show the caption.  This is useful if you need to programmatically change what the "label" is on the front panel such if you are making an application that needs to change its user interface such as for a foreign language.

  • One of my movies I bought shows up on my mac in the itunes library but not on the apple tv.

    I own about 30 movies on my apple tv and one of my movies I bought shows up on my mac in the itunes library but not on the apple tv. How do I fix this issue and get it to show up on my apple tv?

    Two things to check
    1st
    Settings
    Mail, Contacts, Calendars
    AccountsHow many accounts are there?
    2nd
    From Home screen press Mail app
    Press the top left button (next to Inbox)
    You'll see all the Inboxes for the accounts present
    You'll know either way whether one or more accounts has been setup.
    SIDE NOTE: Not too sure about MobileMe though, might be integrated with iCloud, not sure.

  • HT2513 my iCal shows events in the "month" view but not in the "week" view? why is that?

    my iCal shows events in the "month" view but not in the "week" view? why is that? doesnt sync automatically all the time only sometimes

    my iCal shows events in the "month" view but not in the "week" view? why is that? doesnt sync automatically all the time only sometimes

  • Just got a new MacMini.  Migrated files using Time Machine.  However, now, on Launchpad, I see several Firmware updates that were relevant for the old machine, but not for the new one.  How do I get rid of these updates?  They won't delete!

    Just got a new MacMini.  Migrated files using Time Machine.  However, now, on Launchpad, I see several Firmware updates that were relevant for the old machine, but not for the new one.  How do I get rid of these updates?  They won't delete!

    Only thing I can think of is trying this Lion trick...
    http://www.cultofmac.com/106030/how-to-nuke-lions-launchpad-and-start-over/10603 0/

  • How do I access all the Arturia 49 key analog library to Garage Band? I see the analog library but not all the SW instruments?

    how do I access all the Arturia 49 key analog library to Garage Band? I see the analog library but not all the SW instruments?

    Alex,
    have you tried everything in this thread? The problem seems to be different for everybody:
    If nothing helps try dagon's full monty for a reinstall:
    Re: GarageBand '11 won't download additional loops
    Or a manual download using the Terminal as mteep suggests:
    Re: GarageBand '11 won't download additional loops
    Léonie

  • I am not able to format my ipod classic as it is showing in the widows 7 but not in the itunes and when i try to format it, i am not able to format it

    i am not able to format my ipod classic as it is showing in the widows 7 but not in the itunes and when i try to format it, i am not able to format it i am not able to foramt it..

    Hello Ephremekka
    Start your troubleshooting with the article below to get your iPod Classic to show up in iTunes to be restored.
    iPod: Appears in Windows but not in iTunes
    http://support.apple.com/kb/TS1363
    Regards,
    -Norm G.

  • Is there a way to purchase an app from the App store but not use the money I currently have in my iTunes account from a gift card?

    Is there a way to purchase an app from the App store but not use the money I currently have in my iTunes account from a gift card?

    The only way I know is to purchase it as a gift.

  • For about 3 month I receive on my iPhone 3GS iOS6 and my iPad iOS5 empty messages without sender and subject in the mailbox BAL but not in the direct mailbox addresses. I cannot get rid of this messages. Can someone help me.  Thanks

    For about 3 month I receive on my iPhone 3GS iOS6 and my iPad iOS5 empty messages without sender and subject in the mailbox BAL but not in the direct mailbox addresses. I cannot get rid of this messages. Can someone help me.  Thanks !

    Disable Yahoo Messenger (with the arrow on the right of your account name) in Yahoo mail.

  • External speakers work on the Apple side but not on the Windows side - did before but not now - need fix

    New to discussion groups.  Mac-Mini user.  External speakers work on the Apple side but not on the Windows side.  The used to but not now.  need suggestion on fix or do I go to Apple store or a PC repair store?

    Reset the SMC 2-3 times. Click Intel iMac SMC and PRAM resets for instructions.

  • For iPhone 5 why is there a third opening next to the ear speaker on the white phone but not on the black phone.

    why is there a third opening next to the phone speaker (besides the camera) on the white iPhone 5 but not on the black version

    That's probably the ambient light sensor. It's on the black iPhone too, it's just not as visible.

Maybe you are looking for

  • How to change the order of columns displayed in Stacked Canvas

    Dear Member, I have a Stacked Cavas which has many Items. How do i change the order of the Items displayed when the form is opened? I checked the X-Position in the property palette of each item, all the items have an X-position=0. I am really confuse

  • Access to this attachment is blocked. recipients may not be able to view the attachment, either.

    In Office 365 Outlook Web App not able to open attachment sent by infopath list form in as a mail. Please provide the right solution for the same Below is the screenshot for  message, when open the attachment

  • Separate IDOC-Types by mail adapter

    hello together, i have the following problem. a customer sends an order by mail to us. over mail adapter this message goes to the SAP system. the mail-subject contains description where we can separate the single message. this single messages are all

  • Track who deleted data

    A couple of daysa go one the sources defined under payables lookups was deleted. I tried to check who accessed the particular form (FNDLVMLU) by using signon audit reports with no success. Is there some other way i can troubleshoot this? The value re

  • Is there any link between Table PB0002 & HRT1045

    Hi, Applicant Details stored in the Table PB0002 and Rating details i.e. rating for the particular Applicant   stored in the Table HRT1045 but there is no link between these tables . I need to connect these 2 tables for  create a function module to g