How to divide the resultset SQL based on the data in the form of scenarios?

Hello

I need to develop a query that should be divided into scenarios

Ex:

Scenario 1: If a product is sold to the United States and charged in the United Kingdom
Scenario 2: If a product is sold to the United Kingdom and charged in the United States
Scenario 3: If a product is sold and invoiced to the United States
Scenario 4: If a product is sold and invoiced to the United Kingdom

Based on 1 how to divide and provide SQL result to users based on the scenarios?

Ex: Result should show all the data, saying that the result set is in scenario 1, etc..,.

Please advice

Thank you
user12048986

Hello

You can use an expression BOX to classify each line:

CASE  sold_country || ' ' || billed_country
     WHEN  'US UK'     THEN  1
     WHEN  'UK US'     THEN  2
     WHEN  'US US'     THEN  3
     WHEN  'UK UK'     THEN  4
END     AS scenario_num

If sold_country or billed_country is anything except 'UK' or 'US', then the above expression returns null.

I hope that answers your question.
If not, post a small example data (CREATE TABLE and only relevant columns, INSERT statements), and the results you want from this data.

Tags: Database

Similar Questions

  • How to divide the form into 2

    I created an interactive report and a form. By clicking on the button Edit in the report, taking me in a form with all the details of that particular line. Now I want to divide the elements in 2 forms, edit details, and update them at the same time. Pointers or suggestions is appreciated

    Published by: user739459 on August 17, 2011 12:59

    If you want to split because of the logical separation between the elements, you can create a new region and move some items to that. If you want to keep certain items on a single page and some on the other hand, you can copy the page and remove the items is not necessary two pages (except primary key point). Now, create a button on the first page to open the second page, passing the primary key and do the same on page two.

    Lavenu
    MaxApex accommodation
    http://www.maxapex.com

  • How to divide the Dates

    Hi all...

    Here, I use the following scripts...

    create table a10 (eno number, date f, date t, number of sal)

    INSERT IN A10 (ENO, F, T, SAL) VALUES)

    1, TO_Date (1 July 2013 12:00:00 AM ',' DD/MM/YYYY HH: mi: SS AM'), TO_Date (June 30, 2014 12:00 ',' DD/MM/YYYY HH: mi: SS AM')

    (100);

    INSERT IN A10 (ENO, F, T, SAL) VALUES)

    1, TO_Date (May 1, 2013 12:00:00 AM ',' DD/MM/YYYY HH: mi: SS AM'), TO_Date (April 30, 2014 12:00 ',' DD/MM/YYYY HH: mi: SS AM')

    (200);

    COMMIT;

    entry:

    ENO      F             T                SAL

    07/01/2013 2014/06/30 100 1

    1 05/01/2013 30/04/2014 200

    Expected results:

    ENO FTSAL

    1 05/01/2013 2013/06/30 200

    1 30/04/2014 300 07/01/2013

    1 05/01/2014 2014/06/30 100

    I'm little bit confused how to divide the dates here... Any help is appreciated.

    Thank you all

    Stéphane

    Hello

    Always tell what version of Oracle you are using, especially if it's so old.

    In Oracle 10 (or 9, by the way) you can do this way:

    WITH cntr AS

    (

    SELECT LEVEL AS n

    OF the double

    CONNECT BY LEVEL<=>

    )

    got_change_date AS

    (

    SELECT d.eno

    C.n

    WHEN 1 THEN f

    ANOTHER t + 1

    END AS change_date

    C.n

    WHEN 1 THEN 1

    OF ANOTHER-1

    END as mul

    sal

    BY a10 d

    CROSS JOIN cntr c

    -WHERE... - If you need any filtering, put it here

    )

    got_total_sal AS

    (

    SELECT eno

    change_date f

    Advance (change_date) OVER (PARTITION BY eno

    ORDER BY change_date

    ) - 1 AS t

    SUM (sal * mul) over (PARTITION BY eno

    ORDER BY change_date

    ) AS total_sal

    OF got_change_date

    )

    SELECT *.

    OF got_total_sal

    WHERE t IS NOT NULL

    ORDER BY eno, f

    ;

  • How to divide the column Date OBIEE

    Hello
    We have the name of the date column: To_Date and the format is DD/MM/YY hh.
    How to divide the date in YEARS, MONTHS, DAY as new columns.
    kindly help on that.


    Kind regards.
    CHR

    Published by: 867932 on November 23, 2011 22:18

    Hi user,

    All 3 functions can be written in RPD too. MDB layer, duplicate the date column-> the mapping tab to column of Goto-> expression-> functions Builder Select-> calendar Date functions / hour-> select DayofMOnth function. The column of your logic formula will look like,

    DayofMonth (YourDateColumn)

    Rgds,
    DpKa

  • How to add the form designed in adobe acrobat pro live cycle Designer?

    How to add the form designed in adobe acrobat pro live cycle Designer?

    I want to add the form designed in adobe acrobat pro live cycle Designer. I saved the form designed in adobe live cycle designer in pdf format. But you can't change the same in Adobe Acrobat format. I would like to add a few fields and use the fields designed by Adobe Live cycle Designer.

    You can only modify this form in LiveCycle Designer. Forms Acrobat and LCD are not interchangeable.

  • How to divide the Recordset by groups in SQL itself.

    Hi, I use 10.2.4.0 Oracle.
    I have only one requirement, to whom I have to divide the recordset in some groups, so that they can be executed in part, but not in a single pass.

    So, in the 'SELECT' clause itself I want to asssign special value (can be 1) to 50000 first then saves another value (maybe 2) to 10000 next, like wise. And yet once the total number of records will also be successive varry, if the total number of recordset is less than 10,000, then it should only affect '1' to all records. I'll put the values of the Group (1,2,3...) as another column itself.

    Can you please let me know if this can be done in SQL without going for PLSQL?

    Hello

    This is called a Query of paging , and here's a way to do it:

    WITH     got_grp          AS
    (
         SELECT     x.*
         ,     CEIL ( ROW_NUMBER () OVER (ORDER BY  x_id)
                   / 50000
                   )          AS grp
         FROM     table_x  x
    --     WHERE     ...          -- If you need any filtering, put it here
    )
    SELECT     *               -- Or list the columns you want
    FROM     got_grp
    WHERE     grp     = 1
    ;
    

    ROW_NUMBER () OVER (ORDER BY x_id) assigns unique integers 1, 2, 3,... to all of all lines, in the same order as x_id (even if x_id is not unique).
    CEIL (ROW_NUMBER () OVER (ORDER BY x_id) / 50000) maps the 1st 50,000 of these numbers to 1, the 2nd 50 000 votes against 2 and so on.
    Calculated analytical (like ROW_NUMBER) as functions after the WHERE clause is applied, so to use the results in a WHERE clause, then you need calculate their in a subquery. If you want to just display the number and not use in a WHERE clause, so you need not a subquery.

    I hope that answers your question.
    If not, post a small example of data (CREATE TABLE and only relevant columns, INSERT statements) for all of the tables involved and the results desired from these data.
    In the case of a DML (UPDATE), for example, the sample data should show what looks like the tables before the DML, and the results will be the content of the or the tables changed after the DML.
    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}

  • How to divide the three PARTITION HD

    I bought the new PC HP 1350EJ G6

    and

    I would like to divide the PARTITION HD 3: Application of the system, Document,

    Please how can I do?

    Thanks much AVI kl

    {Information}

    Going to be hard to do since you already have 4 primary partitions. See the link below

    http://h30434.www3.HP.com/T5/other-notebook-PC-questions/how-to-REPARTITION-HDD-of-HP-notebook-with-pre-loaded-Windows-7/m-p/742019

  • How to divide the Panel layer in two?

    How do divide you the layers panel in half? I've seen references to do this but Googling this question does not work.

    I use CS2

    Far as I can tell that the person referred to the screenshot of the layers panel appeared in the article, not the real layers panel in Photoshop.

  • How to divide the request to assign a role to multiple users in several.

    Hello

    While we are assigning a role to multiple users OIM11g at the same time, demand has cut several queries to get approved by the Manager of beneficiaries. Please let us know ways to apply the composite to divide the application.

    Why two separate approval process? Instead of two only have a license deal with assignment of dynamic loop based Manager of beneficiary to the owner of the role, and attach it to the level of the operation and you should be good (with auto level template and request approval).
    The child requests are generated only at the level of the operation and NOT to any two previous levels. It is the engine of the application for you.

    -BB

  • How to divide the DB results in addition to a column

    I have some code (see below) which separates the results from a query db in two columns. However, the results print left to right, row by row. Which displays almost correctly, however, I need to display the results of the first half in a column, and the second half of the results in a second column. I can't understand how to change the code to display the first column with 1/2 of the results.


    < CFSET maxcol = 2 >
    < TABLE BORDER = "0" cellpadding = "3" cellspacing = "0" >
    < CFSET outcol = 0 >
    < CFOUTPUT QUERY = "Candidate" >
    < CFIF outcol EQ 0 > < TR > < / CFIF >
    < TD width = "30%" > < span class = "BodyContent" > #Candidate # </span > < table >
    < CFSET outcol = outcol + 1 >
    < CFIF outcol EQ maxcol >
    < /TR >
    < CFSET outcol = 0 >
    < / CFIF >
    < / CFOUTPUT >
    < CFIF outcol NEQ 0 > < /TR > < / CFIF >

    This could be a little Kludgy, but hey, it works...
    First of all, a quick count of the db
    SELECT COUNT (*) AS CandidateCount
    Candidates

    Then divide the total by 2 and 1 for good luck.

    Then write on the table.





    #Candidate #.



  • How to divide the characters in table 1 d

    I am looking for a way to divide the 'print' to a string 1-d subarray. For example instead of:

    1 / AAAABBBB

    2 / CCCCDDDD

    3 / EEEEFFFF

    ...

    etc.

    then there would be two tables 1 d separated where before there was a:

    1 / AAAA and BBBB

    2 / CCCC and Delalande

    3 / EEEE and FFFF

    ...

    etc.

    Something like that?

    You need better on where the split to take place?  I doubt somehow you want just a simple divided into a constant place.

  • How to divide the C: drive into two partitions without a third-party program?

    Hello

    Is there a way to divide the C: drive into two partitions C: and D: on Windows XP without a third pary program?

    If anyone has an idea, please give some steps.

    Thank you.

    Assem

    Hey Assem,

    Once you have created a primary partition, it is not possible (for Windows XP) to divide the partition without using third-party software. You can see:http://support.microsoft.com/kb/309000 to create a new partition.

    I hope this helps...

  • How to divide the string in bb-cascades

    1. I have a table of data as json

      {"RegistrationResult":"Registered Success:Empid:157:TableName:COMPANY156"}
      
    2. Now, how I want to split the show list view in qml and string as the follwing

      Success stories

      EmpID = 157

      TableName = COMPANY156

    3. Please tell the concept of cutting a string and show the result in qml

    I can get the result of the follwing method:

    {"RegistrationResult":["Registered Success","Empid":"157","TableName":"COMPANY156"]}
     
    

    But I do not know how to split the string for a first... Help, please...

    svmrajesh wrote:

    1. ,......"Registered Success:Empid:157:TableName:COMPANY156"}

    Take a look at QString docu

    Just do something like

    myString.split(':')

    and you get a QStringList and this QStringList is directly mapped to a table in QML JavaScript

  • How to divide the amount of import control program command line

    Hi Experts

    Divide the amount of command-line client 102000 99000 and 3000.

    I used following scripts, but he just updated the quantity on the line, but do not add a new line for the remaining quantity.

    1 INSERT IN oe_headers_iface_all
    (
    order_source_id,
    orig_sys_document_ref,
    org_id,
    ORDER_NUMBER,
    CUSTOMER_PO_NUMBER,
    SOLD_TO_ORG_ID,
    CLIENT_NAME,
    CUSTOMER_NUMBER,
    OPERATION_CODE,
    created_by,
    CREATION_DATE,
    last_updated_by,
    last_update_date,
    CHANGE_SEQUENCE,
    FORCE_APPLY_FLAG
    )
    VALUES)
    0,
    "LT_TEST7,"
    204,
    67081,
    "4500007067-01',
    1290
    "Networks of c. a.",
    '1143 ',
    "UPDATE."
    -1,
    SYSDATE,
    -1,
    SYSDATE,
    1,
    « Y »
    );

    2. INSERT IN oe_lines_iface_all
    (
    order_source_id,
    orig_sys_document_ref,
    orig_sys_line_ref,
    orig_sys_shipment_ref,
    org_id,

    ORDERED_QUANTITY,
    ORDER_QUANTITY_UOM,
    PRICING_QUANTITY,
    PRICING_QUANTITY_UOM,
    SOLD_TO_ORG_ID,
    REQUEST_DATE,
    INVENTORY_ITEM,
    created_by,
    CREATION_DATE,
    last_updated_by,
    last_update_date,
    operation_code,
    CHANGE_SEQUENCE,
    CHANGE_REASON
    )
    VALUES)
    0,
    "LT_TEST7,"
    "LT_TESTLINE7,"
    "OE_ORDER_LINES_ALL810289.1,"
    204,
    99000,
    "Ea."
    99000,
    "Ea."
    1290
    AUGUST 13, 2014 '.
    "AS54888,"
    -1,
    SYSDATE,
    -1,
    SYSDATE,
    "UPDATE."
    1,
    'FR '.
    );

    3. INSERT IN oe_lines_iface_all
    (
    order_source_id,
    orig_sys_document_ref,
    orig_sys_line_ref,
    orig_sys_shipment_ref,
    org_id,
    ORDERED_QUANTITY,
    ORDER_QUANTITY_UOM,
    PRICING_QUANTITY,
    PRICING_QUANTITY_UOM,
    SOLD_TO_ORG_ID,
    REQUEST_DATE,
    INVENTORY_ITEM,
    created_by,
    CREATION_DATE,
    last_updated_by,
    last_update_date,
    operation_code,
    CHANGE_SEQUENCE,
    SPLIT_FROM_LINE_REF,
    SPLIT_FROM_SHIPMENT_REF,
    CHANGE_REASON
    )
    VALUES)
    0,
    "LT_TEST7,"
    "LT_TESTLINE7,"
    "OE_ORDER_LINES_ALL810289.1,"
    204,
    3000,
    "Ea."
    3000,
    "Ea."
    1416,
    "05 - SEP - 2014."
    "AS54888,"
    -1,
    SYSDATE,
    -1,
    SYSDATE,
    "INSERT."
    1,
    "LT_TESTLINE7,"
    "OE_ORDER_LINES_ALL810289.1,"
    'FR '.
    );


    Any advice?


    Christy

    Hi all

    The problem was resolved after customer compensation request_id in the header and line, thanks for your help.

    Christy

  • How to divide the Source file into smaller files without export?

    Hi all

    I am a beginner with PPro CS4 and video editing in general. I did a lot of research on Google and the search of these forums for an answer to this question, but I have not found a clear answer. Here's my problem:

    I have many hours of HDV video in recent years with a Canon HV30. This sequence is on dozens of DV tape cassettes. I want to capture most of it on the disk.

    When I capture a band on the disc, I get a single large mpeg4 file. (Body captures all HDV films in mpeg4). "select Scene" does not work with the HV30, so my only way to make a small capture files would be set In/Out points with batch capture. But that would mean hours of fast forward and back with VCR type controls on the camera for the revision of all bands and points. I thought it might be more QUICK to capture everything simply a whole band at once, and THEN examine the band captured the Organization (he is much faster using the Purifier), and by dividing the file into smaller files within the Organization, thus avoiding mechanical advance and rewind on the camera itself.

    But the only way I can find for it seems to imply EXPORT clips. Am I wrong to think that the export of a clip to a new file involves a degradation of the original mpeg4 source file? Or there will be no loss of quality if I simply export to mpeg4 format?

    It seems that there should be an easy way to simply divide the initial capture in small source files for editing later, without putting the images through a new generation of (exporting) treatment, which could result in a loss of quality. Or I'm wrong about this?

    (CS4 Master Suite, i7 3630 k, 16 GB RAM, C: 256 GB SSD, 1 t D:, E: 1 t F3 setpoint setpoint F3)

    HDV film is mpeg2 (which is a number). CS4 is not scene detect you will need to use HDV split for this.

    http://strony.aster.pl/paviko/hdvsplit.htm.

    You can run your files already captured by hdv split and it will cut the file into clips and you leave.

Maybe you are looking for