return all the possible model of a string

Hi all

I would like to return all possible models from a given string, for example when a string is "ABC", I should get

ABC
ADJUSTED COST BASE
TRAY
BCA
CAB
CBA

as well as

AAA
BBB
CCC
ABB
VAC
BAA
BCC
CAA
CBB


I could write this:

Select permut
from (select replace (SYS_CONNECT_BY_PATH (e, ',') ',') permut)
of (SUBSTR ('ABC', level 1) select e)
of the double
connect by level < = length ('ABC'))
connect e nocycle! e = prior)
where length (permut) = 3


but the output is just:

ABC
ADJUSTED COST BASE
TRAY
BCA
CAB
CBA


any ideas? for ora10g or 11g sql/plsql

Thank you

This is similar to the solution of Frank, but somewhat simpler:

with indata as (
  select 'ABC' txt from dual
), chrs AS (
  select substr(txt,level,1) chr
  FROM indata
  CONNECT BY level <= LENGTH(txt)
)
select replace(sys_connect_by_path(chr, '/'), '/', '') permut from chrs
where connect_by_isleaf = 1
connect by level <= (select length(txt) from indata);

[Edit: I guess the main difference is that I don't see the need to SEPARATE.]

Published by: stew Ashton on 18 January 2013 13:58

Tags: Database

Similar Questions

  • How to filter data according to internal application and in case if returns nothing outside the query must return all the lines

    create table ab (a number, b varchar2 (20));

    Insert into ab

    Select rownum, rownum. "" sample "

    of the double

    connect by level < = 10

    create table bc (a number, b varchar2 (20));

    Insert into BC.

    Select rownum + 1, rownum + 1 | "" sample "

    of the double

    connect by level < = 10

    Select * AB

    where b in (select b BC where b = "2sample")

    This query will return me 1 row, but there are cases where the value of the parameter b is null

    and that it should return all rows in the table

    as

    Select * AB

    where b in (select b BC where b = "2sample")

    which return specific values, but I want to change in a way when the inner query returns nothing then outer query should return all the lines and works as

    Select * AB;

    Is it possible to put in a single query

    Hello

    You seem to ask for different things.  You want all the lines AB when

    1. The parameter ("2sample' in the example) is NULL, or when
    2. There is no corresponding row in the 2 tables (which could happen even if the parameter is not NULL)

    ?

    Assuming you want the option 2, here's one way:

    WITH got_rnk AS

    (

    SELECT ab.*

    DENSE_RANK () (ORDER IN CASE

    WHEN b (IN)

    SELECT b

    BC.

    WHERE b = "2sample" - parameter

    )

    THEN "A".

    OF ANOTHER 'B '.

    END

    ) AS rnk

    AB

    )

    SELECT a, b

    OF got_rnk

    WHERE rnk = 1

    ;

    This does not assume b is unique in each table.

    Thanks for posting the CREATE TABLE and INSERT statements; It is very useful.

  • List option Select to return all the options

    Hello

    I created a search form that includes an item called 'AccountType '. This element is a list that is filled by a recordset containing various Types of accounts. The user can select an account type to display data based on their selection. However, I want to include a select option that returns all records of any type of account. List box is...

    < select name = 'AccountType' id = 'AccountType' >
    < option value = "" > all Types of accounts < / option >
    < cfoutput query = "rsAccountType" >
    < option value = "#rsAccountType.AccountTypeId #" > #rsAccountType.AccountType # < / option >
    < / cfoutput >
    < / select >

    Now the "Account Types all the ' option is an empty string, as you can see above that I explored the web and not found the answer. Y at - there some code I can include that make this 'All Types of account' option to return any type of account?

    Appreciate any help!

    Thank you
    Richard

    Answer right under my nose...

    http://www.Adobe.com/cfusion/knowledgebase/index.cfm?id=tn_15746

  • Firefox prompts to save passwords of websites. The key to the Password Manager icon appears on the left side of the address bar, but the corresponding window asking if I want to save the password or not, does not appear. I tried all the possible solutions

    I installed the latest version of Firefox on my laptop (Windows 7 Professional 64-bit). The thing is that firefox prompt to save passwords of websites. I'll explain you a little more away with an example: suppose I load www.gmail.com. When I login, the password manager key is displayed on the left side of the address bar, but the corresponding window which would ask if I want to save the password or not, does not appear. I tried all the possible solutions. It is true that when I restart firefox with disabled modules (safe mode), password manager works fine. But I don't really use Add-ons that could prevent firefox to save passwords. I disabled all add-ons and ran firefox in normal mode, but the password manager does not work yet. Please keep in mind that I tried everything and that any post not published so far describes a similar problem to mine case. Consider that I have the same I have configured the entire system from the beginning. The problem appeared again from the first time I launched firefox. At that time, I had not installed any antivirus software and there is no add-on with firefox. Hope someone can give me a valid solution...

    Start Firefox in Firefox to solve the issues in Safe Mode to check if one of the extensions or if hardware acceleration is the cause of the problem (switch to the DEFAULT theme: Firefox (Tools) > Add-ons > appearance/themes).

    It is possible that there is a problem with key3db and signons.sqlite files that store the encrypted names and passwords in Firefox.

    Rename signons3.txt and signons.sqlite files in the Firefox profile folder.

    You can add .old files (key3.db.old and signons.sqlite.old) names or move them to another folder to make it possible to cancel the action.

    You must define a new master password after renaming or removing the signons3.txt and all the currently saved passwords are lost.

    If that worked, then you can delete the renamed files that are no longer needed.

    See:

  • I have a paid subscription of CC, but it keeps returning all the apps in the "trial" versions

    I have a paid subscription of CC, but on one two computers, it keeps returning all the apps to 'trial' often to 0 days versions. How do the versions "paid / activated ' stick?

    Hi C marwa,

    Please check the help below document:

    Creative Cloud applications unexpectedly back in the test mode. CS6, CCM

    Kind regards

    Sheena

  • Custom code to return all the selected items in a dynamic list

    Does anyone know of a custom code to return all the selected items in a dynamic list? Support told me that Dreamweaver does not return the last item. If anyone can give me a Tips how make this code custom or can direct me to code, I would be eternally grateful.

    Thanks to you two. I used the square brackets since they are in this season...

    No,

  • Find all the possible combinations of grouping

    Hello

    I have a table of color names and must pick up all the possible combinations of color groups. For example, suppose I have the following table: -.
    WITH colours AS (SELECT 1 id, 'red' colour FROM DUAL
                   UNION ALL
                   SELECT 2 id, 'blue' colour FROM DUAL
                   UNION ALL
                   SELECT 3 id, 'green' colour FROM DUAL)
    SELECT *
      FROM colours
    I don't want to get the following results:--
    group  id
    1       1
    2       2
    3       3
    4       1
    4       2
    5       1
    5       3
    6       2
    6       3
    7       1
    7       2
    7       3
    Could someone enlighten me please on how to extract this resultset?

    Published by: tri_harder on April 30, 2010 13:42 updated spelling

    With Oracle 9i:

      1  WITH colours AS
      2       (SELECT 1 ID, 'red' colour FROM DUAL
      3        UNION ALL
      4        SELECT 2 ID, 'blue' colour FROM DUAL
      5        UNION ALL
      6        SELECT 3 ID, 'green' colour FROM DUAL),
      7       m AS
      8       (SELECT COUNT(*) AS max_level
      9         FROM colours)
     10  SELECT   GROUP_ID,
     11           SUBSTR(sp, INSTR(sp, '-', 1, lvl) + 1, INSTR(sp, '-', 1, lvl + 1) - INSTR(sp, '-', 1, lvl) - 1) AS ID
     12      FROM (SELECT     ROWNUM AS GROUP_ID, ID, SYS_CONNECT_BY_PATH(ID, '-') || '-' AS sp
     13                  FROM colours
     14            CONNECT BY ID > PRIOR ID),
     15           (SELECT     LEVEL AS lvl
     16                  FROM m
     17            CONNECT BY LEVEL <= max_level)
     18     WHERE lvl < LENGTH(sp) - LENGTH(REPLACE(sp, '-'))
     19* ORDER BY GROUP_ID, ID
    
      GROUP_ID ID
    ---------- ------------
             1 1
             2 1
             2 2
             3 1
             3 2
             3 3
             4 1
             4 3
             5 2
             6 2
             6 3
             7 3
    

    URS

  • Returns all the values in the table

    Hi team
    I want a query please help
    I have a table emp in that we ename, empno, sal comm

    as

    Select ename, empno, EMP comm
    where comm = 300

    It will run 300 records

    If I don't give any number of comm as null
    so I want to run the date all the
    I user nvl

    as

    Select ename, empno, EMP comm
    where comm = nvl (& comm, comm);

    output: bad.

    Yes, it's the query I use also and is to return all the lines

    SQL > select * from emp where nvl (to_char (comm), '0') = nvl (to_char(&comm), nvl(comm,'0'));
    Enter the value of comm: "
    old 1: select * from emp where nvl (to_char (comm), '0') = nvl (to_char(&comm), nvl(comm,'0'))
    new 1: select * from emp where nvl (to_char (comm), '0') = nvl (to_char (""), nvl(comm,'0'))

    EMPNO, ENAME, JOB HIREDATE DEPTNO COMM SAL MGR
    ---------- ---------- --------- ---------- --------- ---------- ---------- ----------
    7369 SMITH COMMITTED 7902 17 DECEMBER 20 800 80
    7499 ALLEN 7698 1600 20 FEBRUARY SALESMAN 81 300 30
    7521 WARD 7698 1250 22 FEBRUARY SALESMAN 81 500 30
    7566 JONES MANAGER 7839 2975 2 APRIL 81 20
    7654 MARTIN 7698 28 - SEP - 81 1250 1400 30 SALESMAN
    7698 BLAKE MANAGER 7839 2850 MAY 1, 81 30
    7782 CLARK MANAGER 7839 2450 JUNE 9 81 10
    7788 SCOTT ANALYST 7566 3000 APRIL 19, 87 20
    PRESIDENT OF 7839 17 NOVEMBER KING 81 5000 10
    7844 TURNER 7698 08 - SEP - 81 1500 0 30 SALESMAN
    7876 ADAMS 7788 1100 23 MAY CLERK 87 20

    EMPNO, ENAME, JOB HIREDATE DEPTNO COMM SAL MGR
    ---------- ---------- --------- ---------- --------- ---------- ---------- ----------
    7900 7698 DECEMBER 3, CLERK JAMES 81 950 30
    7902 7566 3000 3 DECEMBER ANALYST FORD 81 20
    7934 MILLER COMMITTED JANUARY 7782 1300 23 82 10

    14 selected lines.

    Kind regards
    Navneet

  • Need to find all the possible child records with SQL

    Hello - I am trying to find a way to solve the following with a sql statement:

    I have a table with columns, and the following values:
    Trans_Id   Parent_Trans_id
    1             null
    2             1
    3             2
    4             3
    So basically, 1 is the master parent and I need to bring all ranks, because they are all ultimately originated due to 1. How to write sql code to return all possible levels associated with parent_id = 1?

    I hope I'm communicate that effectively do this, but please let me know if it needs to be clarified.

    Any help is greatly appreciated...

    Thank you
    Christine

    Hi, Christine.

    I think you want to CONNECT BY, something like this:

    SELECT     *
    FROM     a
    START WITH     trans_id      = 1
    CONNECT BY     parent_trans_id      = PRIOR trans_id
    ;
    

    I hope that answers your question.
    If not, post a small example data (CREATE TABLE and only relevant columns, INSERT statements) and also publish outcomes from these data.
    Explain, using specific examples, how you get these results from these data.
    Always tell what version of Oracle you are using.
    See the FAQ forum {message identifier: = 9360002}
    You will find the answers better faster if you always provide this information whenever you post a question.

  • A query to return all the SQL executed for a particular user instructions.

    Hello

    Is it possible to find all the instructions SQL for a particular user using the views v$? I can do it 10g but I am currently using 9i, the query below does not work.
    select a.username,a.logon_time,b.sql_fulltext 
    from v$session a,v$sqlarea b 
    where a.sql_id=b.sql_id
    and a.username='USER'
    order by a.logon_time desc
    I guess that some columns in these views do not exist in 9i. The output of 9 that I use is 9.2.0.1.0.

    Your help is very appreciated.

    Thank you
    Select this option.

    Dear mark!

    I suggest you use the audit instead of v$ sqlarea. Onlinedocumentation said the next thing Oracle v$ sqlarea:

    >
    V$ SQLAREA lists statistics on the shared SQL area and contains a line by the SQL string. It provides statistics on SQL statements that are stored, analyzed and ready for execution.
    >
    This means that you will only get the SQL statements that are currently in memory. Older statements which are already deleted from memory are not visible for your query.

    Incidentally, if you simply want to know what's wrong with your query then please post your errormessage.

    Yours sincerely

    Florian W.

    Published by: Florian W. the 29.07.2009 12:03

  • Cannot change the privacy of my story setting. He always comes back to save history. I tried all the possible solutions without change. Any help for this problem?

    I tried to change my privacy settings for history to remember the history of custom settings and he returned always to remember history. I tried all the fixes including refreshing Firefox, by removing the prefs.js file, check my Norton Security Suite to be sure that Firefox Cleanup is disabled, synchronization is turned off and all the other recommendations I can find with an online search of the problem. Another that a deletion total Firefox and fresh installation is there any other recommendation that I can try allowing the change in my setting of the story.
    The reason why I ask is recently that my browser does not store cookies permanently. When I try to enter a password sites (my Bank for example), I have to answer a question before you enter my password. I have to do this every day. Previously, I was able to save the computer and should not be the question that arises, unless I have cleared my cache, history and cookies. However, it seems that cookies seem to disappear when I close the computer power off or after an unknown period of time and I have to go through the procedure to properly identify myself and my computer on the site. This is a private computer with no access by someone else and it became cumbersome to re-enter the requested information whenever I go to some of my usual sites.
    I use Windows 7 Ultimate with 37.0.1 Firefox as my browser. Any help is greatly appreciated.

    The problem only occurs when you restart Windows and not between the closing and startup of Firefox without having to restart Windows?

    Outside Norton, do you have any other utility that can 'clean up' browser like CCleaner settings?

  • Firefox always displays all the possible options in the context menu

    When I select some text on a web site and right-click, I get a popup menu with about 50 options.

    Some earlier, archived posts have addressed one of the causes of this - extensions - but disable my extensions and restarting did not work for me. I always get the context menu options-50.

    Here are the previous posts:
    https://support.Mozilla.org/en-us/questions/955270
    https://support.Mozilla.org/en-us/questions/951383

    Do a clean reinstall and remove the Firefox program before (re) install a new copy of the current version of Firefox.

    Download a new copy of Firefox and save the file to the desktop.

    If possible to uninstall your current version of Firefox to clean the Windows registry and settings in the security software.

    • Do NOT remove the "personal data" when you uninstall your current version of Firefox, because this will remove all profile folders and you lose personal data such as bookmarks and passwords including data profiles created by other versions of Firefox.

    Remove the Firefox program before installation newly downloaded copy of the Firefox installer.

    • (32-bit Windows) "C:\Program Files\Mozilla Firefox\"
    • (Windows 64 bit) "C:\Program Files (x 86) \Mozilla.

    Your bookmarks and other personal data are stored in the Firefox profile folder and will not be affected by a uninstall and (re) install, but make sure that 'delete personal data' is NOT selected when you uninstall Firefox.

    If you keep problems also create a new profile.

  • Function to return all the variables in the expression list on 50 G?

    What is the function on the 50G will return all variables used in algebraic exoression list?

    Example entry:

    (x + y) ^ z / x

    output:

    {x y z}

    Hello Chris_Chen,

    the command "LNAME" does what you want, but you get the result as a vector, not a list.

    For example: ' Q ^ 2 - SIN (XT)'-> [Q XT]

    But this can be easily converted into a list: < < OBJ-> OBJ-> MENU-> LIST > >

    Cordially calcpeace

  • {module_faqresults} returns all the FAQS on the opening page (includes screenshots)

    Hello, I am going through a book about Business Catalyst and it was written before this new version, so things are not as clear. The book does not show what is currently happening with module FAQ Business Catalyst.

    When I include the FAQ Module Business Catalyst search engine, it adds the {module_faqresults} automatically and when you view the page in a browser instead of wait for a search term be added to the input box and searched, the default page to all the frequently asked questions in the database.

    So if you search for a term he will return only the elements of the search term. How can you get to not display all of the FAQS as soon as the page opens and wait until someone actually searching for something and then return these results?

    I've included several pictures to explain what I mean.

    Thanks for your help.

    post03-01.jpg

    post03-02.jpg

    post03-03.jpg

    post03-04.jpg

    Sorry about that, there's a typo in the code, please delete this empty space here - http://screencasteu.worldsecuresystems.com/Mihai/2012-09-03_1233.png

    If you ae still problems after removing space send me a PM with the URL and I'll have a look. Here's a test page on my site with this script in place - http://www.uktest00.co.cc/faqtest

    Hope this helps,

    Mihai.

  • Returns all the duplicate values in object lookup (PHP, drop-down list)

    Hi, I have a PHP page I designed as a search page. I have a number of drop-down lists that get their dynamic values from the fields in a MySQL database.

    At present, if there are any entries that have duplicate values in a certain area, they are all listed, in the order of the index database. For example:

    City:

    Derby

    Stoke

    Stafford

    Stoke

    Derby

    Derby

    Stoke

    etc...

    Now, I want to do is be able to show all results for a given city. In the find what drop-down list box, I would than each of the cities to appear only once rather than every time it is registered. included in this, I would like the page of results to then display ALL results that match this search criteria.

    Thus, in the example above, "Derby" appears only once, but when the user has selected 'Derby', it would return all three results in the results page.

    My results page is built on a dynamic form, so I am confident that the results page would make it according to the needs. However, how can I get the drop-down list box to ask him?

    > 'SELECT DISTINCT table1.champ1, table1.champ2, table1.champ3 FROM Table1 ";

    Duplicate rows to remove the DISTINCT keyword strength SQL. In other words, that it will only return the unique combinations of fields in your selection list. If you examine your results set, you will see that each line is separate, although there may be duplicates in a particular area. Because you want to populate a drop-down list, you must include a field in your select list only, otherwise you get of the dupes.

Maybe you are looking for

  • HP Envy 700-327c: graphics card on HP Envy 700-327c update

    I just bought and am preparing to install an AMD over-pants W7000 C2K00AT 4 GB GDDR5 SDRAM PCI Express 3.0 x 16 ATI Nvidia Quadro graphics in my HP Envy 700 - 327 c.  Any input as to what I can do to make this a free update of the problem?

  • Pavilion DV7: upgrading ram on laptop

    What is the maxiumum ram I can put in this laptop - I 8 - but go to 16 - this laptop that much?

  • 1010NR HP mini slider jams-up

    Just bought a HP mini 1010nr. I love it, except for one problem. When I move the cursor upwards or downwards it jams and this funny little money search rectangle appears at the end of the needle. It's a random thing, however. But there are enough to

  • Bad quality when taking backlit pictures

    Hello, I have a problem with the poor quality of the photos when shooting to light. I tried all modes in the stage and was unable to remove the spotlight. Also one with the same problem with the video software Rev: 23.4.A.1.232 photo examples: https:

  • Wake from sleep?

    My HP Photosmart 7520 new e-all-in-on the series must be woken up physically. After that he goes to sleep, I have to go and turn the wifi market until I can send a command to print from a computer or an iPad. Why a wifi printing command not wake the