Query to get a combination of values

I have 4 tables, say T1,T2,T3,T4.
I want to select 4 columns from this 4 tables respectively.
How can I write a query to fetch all possible combinations of these 4 columns.

The only way to combine columns is to write a SQL statement where you written possible combinations of these columns.
You can develop something to combine the values but you can't manipulate columns very easily.
SQL> SELECT ENUMERATIONS.PERMUTA(STRING_TABLE('A','B','C'))
  2  FROM DUAL
  3  /
ENUMERATIONS.PERMUTA(STRING_TABLE('A','B','C'))
STRING_TABLE('ABC', 'ACB', 'BAC', 'BCA', 'CAB', 'CBA')
SQL>To do it I use the following package.
CREATE OR REPLACE
TYPE string_table as table of varchar2(4000)
CREATE OR REPLACE
PACKAGE enumerations is
     type bool_tab is table of boolean index by binary_integer;
     flags bool_tab;
     solutions string_table;
     function permuta (
          strings in string_table
     ) return string_table;
end enumerations;
CREATE OR REPLACE
PACKAGE BODY enumerations is
     procedure permutations (
          i in pls_integer,
          strings in string_table,
          current_string in varchar2
     is
          n pls_integer;
          j pls_integer;
     begin
          n := cardinality(strings);
          if ( i <= n ) then
               for j in 1..n loop
                    if ( not flags(j) ) then
                         flags(j) := true;
                         permutations(i+1,strings,current_string||strings(j));
                         flags(j) := false;
                    end if;
               end loop;
          else
               solutions.extend();
               solutions(solutions.last) := current_string;
          end if;
     end;
     function permuta (
          strings in string_table
     ) return string_table
     is
     begin
          for i in 1..cardinality(strings) loop
               flags(i) := false;
          end loop;
          solutions := string_table();
          permutations(1,strings,'');
          return solutions;
     end;
end enumerations;
/Bye Alessandro

Similar Messages

  • Query to get parameter name and value after ran the conccurent program

    Hi All,
    Query to get the parameter name and value for completed concurrent program using the request id. can any one help me in this regard.
    Thanks,
    Red.

    Red,
    I have tried the same query and it works properly here.
    I have submitted "Purge Signon Audit data" concurrent program with "Audit Date" parameter set to 01-06-2009, and here is the query output:
    SQL> select request_id, phase_code, status_code,
    argument_text, argument1
    from fnd_concurrent_requests
    where request_id = '739664';
    REQUEST_ID P S ARGUMENT_TEXT        ARGUMENT1
        739664 C C 2009/06/01 00:00:00  2009/06/01 00:00:00Regards,
    Hussein

  • Query to get row with max values for distinct

    I have a table test with ID, ADID, MTMST columns.
    ID     ----ADID----     MTMST
    1     ----100----     24-MAR-12 08.17.09.000000 PM
    1     ----101----     24-MAR-12 08.18.15.000000 PM
    1     ----102----     24-MAR-12 08.18.56.000000 PM
    2     ----103----     24-MAR-12 08.19.21.000000 PM
    2     ----104----     24-MAR-12 08.19.36.000000 PM
    2     ----105----     24-MAR-12 08.19.46.000000 PM
    3     ----99----      22-MAR-12 09.48.22.000000 PM
    I need the rows with max ADID for each ID.
    I used the following query but it provided max ADID of the table but not the distinct ID
    select * from test where ADID in (select max(ADID) from test where id in (select distinct(id) from test where mtmst > sysdate -1))
    Result:*
    ID     ----ADID----     MTMST
    2     ----105----     24-MAR-12 08.19.46.000000 PM
    Expected result:*
    ID     ----ADID----     MTMST
    1     ----102----     24-MAR-12 08.18.56.000000 PM
    2     ----105----     24-MAR-12 08.19.46.000000 PM
    Thanks,
    Dheepan
    Edited by: Dheepan on Mar 24, 2012 9:53 AM

    select id, adid, mtmst from test where (id, adid) in (select id, max(adid) from test group by id) and MTMST>sysdate-1
    is the answer.

  • Query help : Query to get values SYSDATE-1 18:00 hrs to SYSDATE 08:00 hrs

    Hi Team
    I want the SQl query to get the data for the following comparison : -
    Order Created is a Date Column , and i want to find out all the values from (SYSDATE-1) 18:00 hours to SYSDATE 08:00 hours
    i.e.
    (SYSDATE-1) 18:00:00 < Order.Created < SYSDATE 08:00:00.
    Regards

    Hi, Rohit,
    942281 wrote:
    If i want the data in the below way i.e.
    from (SYSDATE-1) 18:00 hours to SYSDATE 17:59 hours ---> (SYSDATE-1) 18:00:00 < Order.Created < SYSDATE 07:59:00.If you want to include rows from exactly 18:00:00 yesterday (but no earlier), and exclude rows from exatly 08:00:00 today (or later), then use:
    WHERE   ord_dtl.submit_dt  >= TRUNC (SYSDATE) - (6 / 24)
    AND     ord_dtl.submit_dt  <  TRUNC (SYSDATE) + (8 / 24)
    So can i use the below format : -
    ord_dtl.submit_dt BETWEEN trunc(sysdate)-(6/24) and trunc(sysdate)+(7.59/24) . Please suggest . .59 hours is .59 * 60 * 60 = 2124 seconds (or .59 * 60 = 35.4 minutes), so the last time included in the range above is 07:35:24, not 07:59:59.
    If you really, really want to use BETWEEN (which includes both end points), then you could do it with date arithmentic:
    WHERE   ord_dtl.submit_dt  BETWEEN  TRUNC (SYSDATE) - (6 / 24)
                      AND         TRUNC (SYSDATE) + (8 / 24)
                                               - (1 / (24 * 60 * 60))but it would be simpler and less error prone to use INTERVALs, as Karthick suggested earlier:
    WHERE   ord_dtl.submit_dt  BETWEEN  TRUNC (SYSDATE) - INTERVAL '6' HOUR
                      AND         TRUNC (SYSDATE) + INTERVAL '8' HOUR
                                               - INTERVAL '1' SECONDEdited by: Frank Kulash on Apr 17, 2013 9:36 AM
    Edited by: Frank Kulash on Apr 17, 2013 11:56 AM
    Changed "- (8 /24)" to "+ (8 /24)" in first code fragment (after Blushadown, below)

  • Get a insert session value for SQL query at report

    Hi friends
    I created a global temp table and procedure to support web search form.
    and a search result report. The procudure
    gets search result from multip tables and
    insert into temp table --recordsearch. I can get value from temp table  by call procedure
    at SQL*Plus.
    However, I can not get this value by web report.
    How can I get this insert session value and pass to SQL query for report?
    Thanks,
    Newweb
    CREATE GLOBAL TEMPORARY TABLE recordsearch
    (emp_id          VARCHAR2(200),
    ssn               VARCHAR2(9),
    fname          VARCHAR2(200),
    lname           VARCHAR2(200),
    m_name          VARCHAR2(200)
    ) ON COMMIT PRESERVE ROWS;

    it possible that your web form does not have a persistent, dedicated connection. if you have connection pooling for example, multiple sessions will see the same instance of the GTT, so if one deletes it, then nobody sees it (or you can see others data). if the connections are not persistent, then they can disconnect between calls, deleting the GTT table.

  • How to get Input-Ready Cell  Value of Input Ready Query?

    Hi,
    How to get input ready cell value in fox formula?
    for example :
    In Input-Ready Query,
    C_Code Month        Psale(input ready)
    1000          05.2012       800
    now i want Psale 800 in fox formua before value save in cube,
    is it possible?
    Thanks
    Ravi

    Hi,
    as I understand your requirement: you want to execute a planning function before 'save'. This possible, cf. note 1356805
    for more details.
    Regards,
    Gregor

  • Query to get possible values for each segment

    Hi Gurus,
    Give the flex value set id, what is the query to get all possible values for each segment (just like what is shown in the accounting flex window)?
    Thank you,
    Beibei

    Hi Beibei,
    The table FND_FLEX_VALUES_VL can give you details of values available in the Value set i.e. 1 segment at a time.
    If you are looking for a concatenated view of Accounting Flexfield values, that would be available in GL_CODE_COMBINATIONS table.
    Regards,
    Ivruksha

  • SQL query to get the Datetime 06 hours prior to the table Datetime value

    Hi Experts,
                    I'm just trying to create a SQL query to get the Datetime which should be 06 hours prior to my Table column value(Executiontime),
    Eg: my Executiontime(column) value is 07:00AM means, this query should fetch the detail of first VMName from table at 01:00AM, 
    SQL Table Name: TestTable
    Columns: VMName(varchar),status(varchar) Executiontime(Datetime)
    SQL Query : Select Top 1 VMName from
    TestTable where convert(date,Exeutiontime)=convert(date,getdate()) and
    status='0' and ExecutionTime > dateadd(hour,6,getdate())
    Request someone to alter this Query to my requirement or give me the new one.
    Regards,
    Sundar
    Sundar

    Hi All,
            Thanks for your Prompt response. I tried the below queries, but still I don't have any luck. Actually the queries are returning the value before the condition met (say when the time difference is more than 06 hours). I want the
    query to return exactly @ 06 hour difference or less than 06 hours,
    Query 01: Select Top 1 VMName from TestTable where
    convert(date,Exeutiontime)=convert(date,getdate())
    and status='0'
    and ExecutionTime >
    dateadd(hour,-6,getdate())
    Query 02: Select
    Top 1 VMName from TestTable where
    status='0'
    and ExecutionTime >
    dateadd(hour,-6,getdate())
    Query 03: Select
    Top 1 VMName from TestTable where status='0'
    and ExecutionTime >
    dateadd(hour,-6,ExecutionTime)
              Can someone point out the mistake please.
    Regards,
    Sundar
    Sundar

  • Needs Query to get the cycle time automatically based on the value provided in the UDF on OWOR  table

    Dear all,
    Need a query to get the Cycle time in hr based on the value provide in the udf on OWOR table.
    Details of UDF:-
    1.Start date =10/07/14  (Field Name U_EA_REST)   
    2.Start time =10:00        (Field Name U_EA_REASTARTTIME)
    3.End date =11/07/14    (Field Name U_EA_REET)
    4.End Time=14:00          (Field Name U_EA_REAENDTIME
    Cycle Time=_______      (Field Name U_EA_REACYCLETIME)
    Regards,
    BanugopanRajendran

    Dear all,
    Need a query to get the Cycle time in hr based on the value provide in the udf on OWOR table.
    Details of UDF:-
    1.Start date =10/07/14  (Field Name U_EA_REST)   -  Date Type
    2.Start time =10:00        (Field Name U_EA_REASTARTTIME) - Hour Type
    3.End date =11/07/14    (Field Name U_EA_REET) - Date Type
    4.End Time=14:00          (Field Name U_EA_REAENDTIME - Hour Type
    Cycle Time=_______      (Field Name U_EA_REACYCLETIME) - Hour Type
    Regards,
    BanugopanRajendran

  • How to run user enter value query and get result on Text item

    Hi ,
    I'm really newbie at JDeveloper and ADF , I want to run the query below , before with Forms i just adding :TEXT_NAME to get the entered users value , what I have to do now with ADF , really it's not clear question and I would appreciate any help with this ,
    select
    nvl(min(substr(a.starttime,1,8)),0) Service_Start_Time, nvl(sum(a.sessionvolume),0) Total_Traffic_KB
    FROM
    aaa_bill a
    where
    msid=:TEXT_ITEM
    and starttime >=(select max(fee) FROM aaa_bill
    where msid=:TEXT_ITEM and accountreason=5) ;

    You can use a ADF parameter form for this requirement.
    https://blogs.oracle.com/shay/entry/combining_multiple_queries_and

  • Query to get value sets associated with its descriptive flexfield

    Hi All,
    Here i have a issue
    I am trying to get Value sets associated with its descriptive flex field of Receivable application and
    also if i want this for particular responsibility i.e., GW RBC Receivable Super User.
    I hope u got it.
    Please suggest me some query to get this.
    This is very important for me.

    Hi, I think your question should be addressed to the OEBS experts

  • Lookup query to get Manager ID value on object form

    Hi ,
    I have created a Manager ID field on object form which is of type lookup field.
    Can any one please tell me that how can i write Lookup query to get Manager ID value on object form.
    Thanks in Advance

    I was looking for something like this today too.
    Here's what I came up with:
    SELECT fu.user_id, fu.employee_id, fu.user_guid, pe1.full_name, pe2.full_name SUPERVISOR, pe2.employee_id
    FROM fnd_user fu
    JOIN per_employees_x pe1 on pe1.employee_id = fu.employee_id
    JOIN per_employees_x pe2 on pe2.employee_id = pe1.supervisor_id
    WHERE fu.user_id = $(user_id)
    Edited by: user12232265 on Feb 24, 2010 3:20 PM

  • SQL query to get last 10 records in the table?

    Hi,
    Can anyone tell me the SQL query to get last 10 records in the table?
    Thanks!!
    MCP

    Please, define what "last" means. Sets are unordered by definition, so if you want to retrieve rows from a table in a specific order you need to specify what that order is - e.g. by maintaining a value in a column (or a combination of columns) that you can use in the ORDER BY clause of the SELECT statement.
    If, for instance, you kept the time when the row was inserted in a special column (InsertedTime), you could use this in your query like this:
    select top (10)
      <column list>
      from <table or view>
      where <restriction(s)>
      order by InsertedTime desc;
    ML
    Matija Lah, SQL Server MVP
    http://milambda.blogspot.com

  • Can we combine prompt values in Webintelligence Report(Combined Q:Union)

    Hi Every One,
    I had 4 Queries which are combined queries(Union).When i run the report ,displaying prompt values which are there in first Query.Can't we get combined prompt values when i run the report.I will explain with Scenario.
    Eg:
    Q1:Product level Country Information
    Prompt Values:Country(A,B,C,D,E,F,G,H)
    Q2:Component level Country Information
    Prompt Values:Country(A,B,C,D,E,F,L)
    Q3:Product level Source Information
    Prompt Values:Country(A,B,C,D,E)
    Q4:Product level Country Information
    Prompt Values:Country(A,B,C,D,E,F,M)
    When i run the report iam getting prompt values for country as (A,B,C,D,E,F,G,H)
    Could you help .
    Regards,
    Swapna.

    I'm having trouble understanding your scenario as you explain it.
    You are doing a union of the queries?
    So create query A, combine queries, union, create query B, etc.
    All of them use the same prompt message?
    So you either build the condition and reuse the same prompt message or you use a filter from the universe.
    In this case it is not possible to specify something different for each of the various subqueries.
    So you would have only one prompt answer, being whatever you answered to the prompt.
    If you have different prompt messages, you can give different answers, but then you have 4 prompt answers to display.
    It would be logical that only the first one is displayed if that is the one you display, you should display all four.
    If you just want to display the superset of countries which have been retrieved by the query you can put this information in a separate table block. If you make it a horizontal one, without borders, you should be able to come close to a normal prompt layout.
    Good luck,
    Marianne

  • Not able to get the profile option value

    Hi,
    Not able to get the profile option value after i changed the new value in the application.
    I am using fnd_global.apps_initialize to initialize the apps from PLSQL code to get the updated profile option value. But fnd_profile.value is not getting fetched the updated value. Still it is fetching the old one. I mean it is stored in database cache. Please any one let me know how to get the new value every time after i changed the value.
    Thanks

    What is the application release?
    Is this a custom or seeded profile option?
    Can you confirm that the value got changed from the application (query the profile option and verify the value)?
    Can you reproduce the issue if you use an API to update this profile option as per (How to Change Profile Option Value Without Forms? [ID 943710.1])?
    Thanks,
    Hussein

Maybe you are looking for

  • IPhone 5 not getting all texts from Galaxy S6

    My girlfriend is having a problem not getting all of my texts. As far as we know, it is only happening to texts from my phone. They are showing as sent on the Galaxy S6, but do not show up, ever, on her iPhone 5. The missing messages are random. 

  • Phtoshop CS 2 - Web Photo Gallery - "Flash - 1 Gallery"

    I'm using Flash 8 Pro. I'm interested to know the code that Adobe Uses with one of their Web Photo Gallerys (Photoshop CS2) - it's the one called "Flash - Gallery 1". Here's a sample of it: http://www.newrisedesigns.com/charlie/060416/ What I'm inter

  • What is the highest bitrate syncable to iPhone 4S?

    I was just wondering what the highest bitrate syncable to iPhone 4S was?

  • ICloud lost data - inbox suddenly empty.

    All messages in my inbox just disappeared.  New messages seem to be coming in as usual, but anything before this morning is gone.  I checked in multiple clients, my iPhone, and on the web.  They're all gone.  Any suggestions?

  • Uploading to FTP Host

    Anyone know where I can find this folder and/or why I am getting this message? I'm unable to publish my site. Thanks! Zach