Select help request - integrated

Hello

The following query will show me the catalog ID and Descriptions of all the outfits hired
for each branch, with revenues generated in descending order...
SELECT Members_Order.Catalogue_ID, Item.Item_Description, Item.Colour Orders.Branch_ID, Item.Hire_Charge, Members_Order.Number_of_Days, (Hire_Charge*Number_of_Days) AS Total
From Members_Order, Item, Orders
WHERE Members_Order.Item_ID = Item.Item_ID
AND Members_Order.Order_ID = Orders.Order_ID
ORDER BY Total DESC;
What I want to do now is to create a query to display the details of the outfits, which are the same color as the suit that has generated the most revenue. I'm guessing that this will involve a choose embedded, using the base of the query above, but I'm not sure about what should go with the select embedded?

I have the following to this day, could someone help me finish or point me to the right direction...?
SELECT Members_Order.Catalogue_ID, Item.Item_Description, Item.Colour, Item.Hire_Charge, Members_Order.Number_of_Days, (Hire_Charge*Number_of_Days) AS Total
From Members_Order, Item, Orders
WHERE Members_Order.Item_ID = Item.Item_ID
AND Colour = (SELECT Colour FROM Item WHERE 
;
Published by: user10945931 on April 15, 2009 19:50

Hello

I'm surprised that ran at all.

I made a mistake in my previous answer. The second line of SELECTION (right before ROW_NUMBER) shouldn't be there at all. My apologies.
Here's what I meant:

WITH  ranked_data  As
(
     SELECT  Members_Order.Catalogue_ID
     ,     Item.Item_Description
     ,     Item.Colour
     ,     Orders.Branch_ID
     ,     Item.Hire_Charge
     ,     Members_Order.Number_of_Days
     ,     (Hire_Charge * Number_of_Days)     AS Total
     ,     RANK () OVER (ORDER BY Hire_Charge * Number_of_Days DESC)
                                               AS rnk
     FROM     Members_Order
     ,     Item
     ,     Orders
     WHERE     Members_Order.Item_ID     = Item.Item_ID
     AND     Members_Order.Order_ID     = Orders.Order_ID
)
SELECT     *     -- or list all columns except rnk
FROM     ranked_data
WHERE     colour  = (
            SELECT  colour
            FROM       ranked_data
            WHERE       rnk     = 1
            );

Tags: Database

Similar Questions

  • Select help request

    Oracle version 10.2.0.2.0

    Can I write in a single SQL aside the function instead of if... else. I tried with the case but not thru. Please advice

    FUNCTION mark_place

    (

    i_year in NUMBERS

    i_month in varchar2,

    i_school_code in varchar2,

    i_paper_code in varchar2,

    i_condition in varchar2)

    Return number

    IS

    number of mark_count;

    Start

    IF i_condition = "COMPLETE" THEN

    Select count (criteria_mark_status) in mark_count

    of ssn_yes

    where school_code = i_school_code

    and year = i_year

    and month = i_month

    and paper_code = i_paper_code

    and criteria_mark_status = "COMPLETE";

    on the other

    Select count (criteria_mark_status) in mark_count

    of ssn_yes

    where school_code = i_school_code

    and year = i_year

    and month = i_month

    and paper_code = i_paper_code

    and criteria_mark_status! = "FULL";

    END IF;

    Return mark_count;

    end mark_place;

    An option

     select count(criteria_mark_status) into mark_count
        from ssn_yes
        where   school_code = i_school_code
        and year = i_year
        and month = i_month
        and paper_code = i_paper_code
        and (case
                when i_condition = 'COMPLETE' and criteria_mark_status  = 'COMPLETE' then 'VALID'
                when i_condition != 'COMPLETE'and criteria_mark_status  != 'COMPLETE' then 'VALID'
          end) = 'VALID';
    

    See you soon

    AJ

  • When I select Help and support icon, I get an error message indicating that the feature could not start.

    help and support does not work

    When I select Help and support icon, I get an error message indicating that the feature could not start.

    I use a Vista 32 bits on a HP computer operating system model number m8300f.

    In addition, I bought a copy of Win 7, but who could not load freezing during installation.

    Hello

    Try to run the command in the elevated command prompt, follow the steps below, it could help us solve the problem.

    1. open the start menu, click programs principally made, select accessories.
    2. right click on command prompt, and then click "run as administrator ".
    3. type the following commands in the DOS prompt window and press ENTER at the end
    of each line:

    REGSVR32 MSXML3. DLL/U
    REGSVR32 MSXML3. DLL
    REGSVR32 MSXML6. DLL/U
    REGSVR32 MSXML6. DLL

    (At the elevated command prompt command should not give us any error).

    Restart the computer and try to access help and Support.

    For the problem of installation of windows 7.

    We would like to get more information about you to help solve your problem. You better, please answer the following questions.

    1. How did you start the installation process?

    2. you perform a new installation or an upgrade?

    3. what type of drive you are using for installation?

    4. at what stage of the installation has it stopped?

    5. have you received an error message?

    First of all, I would say that you disconnect external devices connected to the computer except the keyboard and mouse.

    If you have performed an upgrade suggests to restart the computer and you will be prompted for a roll back option.

    Once you're on the office suggests to run Upgrade Advisor and check what needs to be done before you start the upgrade.

    Before you begin the upgrade process to ensure that your computer meets the condition of equipment to install Windows 7 and check on the website of manufacturer computer if the computer is good to run windows 7 or not.

    Installing and reinstalling Windows

    http://Windows.Microsoft.com/en-us/Windows7/installing-and-reinstalling-Windows

  • Help request for C:\windows\system32\config\system / Bad Pool Caller / on xp

    . Hi, I have xp sp3, and after the established cat off for switching on the pc appears the error message mentioned.  I tried f8 for boot from the sp3 installation CD and ends up with the BAD_POOL_CALLER message.  That's why I can't launch 'r' for recovery apparently safe mode.  Any suggestion would be appreciated before gratefully the cat gets it... Thank you.

    Well, if you can start on some CDs and get to a command prompt on your HARD drive, you should be able to implement the suggestion of KB307545 of Microsoft Support Engineer Halima S and "check if it helps" (I don't think it will be).

    Here's how you describe / have symptoms that indicate the need to use KB307545:

    Zero

    If you want to make a bootable CD from the Console of the Recovery XP (no XP media required) and then to implement the proposal of Microsoft Support Enginner Halima S and check if it helps.

    Here's how:

    Boot into the Recovery Console Windows using an XP bootable installation CD.

    If you have no XP bootable media (or aren't sure you have) create a bootable XP Recovery CD of Console and do not forget.

    This is not the same as recovery disks that might have come with the acquisition of the system store.

    You can make a bootable Recovery Console CD by downloading an ISO file and burn it to a CD.

    The ISO bootable image file you need to download is called:

    xp_rec_con. ISO

    Download the ISO from here:

    http://www.mediafire.com/?ueyyzfymmig

    Use a new CD and this simple and free program to burn your ISO file and create your bootable CD:

    http://www.ImgBurn.com/

    When you install ImgBurn, DO NOT install the Ask toolbar.

    Here are some instructions for ImgBurn:

    http://Forum.ImgBurn.com/index.php?showtopic=61

    It would be a good idea to test your bootable CD on a computer running.

    You may need to adjust the computer BIOS settings to use the CD-ROM drive as the first device to boot instead of the hard drive.  These adjustments are made before Windows tries to load.  If you miss it, you will need to restart the system again.

    When you start on the CD, follow the instructions:

    Press any key to boot from CD...

    Installing Windows... going to pronounce.

    Press 'R' to enter the Recovery Console.

    Select the installation that you want to access (usually 1: C:\WINDOWS)

    You may be asked to enter the password (usually empty).

    You should be in the folder C:\WINDOWS.  It's the same as the

    C:\Windows folder that you see in Solution Explorer.

    The Recovery Console allows base as file commands: copy, rename, replace, delete, chkdsk, fixboot, fixmbr, cd, etc.

    For a list of the commands in the Recovery Console, type help at the prompt of commands or read on here XP Recovery Console:

    http://www.Microsoft.com/resources/documentation/Windows/XP/all/proddocs/en-us/recovery_console_cmds.mspx?mfr=true

    When you get into RC, is if you can run a chkdsk/r...  Here's how:

    A good idea before you start things must first verify the integrity of your file system by using the chkdsk command.

    In the command prompt window, run the chkdsk command on the drive where Windows is installed to try to fix any problems on the afflicted player.

    Running chkdsk is fine, even if he finds no problem.  It won't hurt anything to run it.

    Assuming your boot drive is C, run the following command:

    CHKDSK C: /r

    Let chkdsk finish to correct the problems, he could find.

    It may take a long time for chkdsk complete or they seem to be "stuck".  Be patient.  If the HARD drive led blinks always, chkdsk is something.  Keep an eye on the amount of the percentage to be sure that it is still making progress.  It may even seem to go back sometime.

    You must run chkdsk/r again until it finds no error to correct.

    Remove the CD, and then type "exit" to exit the RC and restart the computer.

    You have not to set the BIOS to boot the disk HARD since the CD won't be.

  • Need help request!

    Hi all

    I am faced with a request to generate a model:

    The problem is the following:

    I have a test table in

    create table test

    (

    Identification number,

    varchar2 (20 char) value,

    date date

    );

    and the row values are as follows:

    value date: ID:

    1:value1:Date1

    1:value2:date2

    1:value3:date 3

    where date1 is today, date2 is yesterday and date 3 is the day before yesterday.

    I have to generate a format like below:

    ID: old_value:new_value:changed_date

    1:value3:value2:date2

    1:value2:value1:Date1

    where id, old_value, new_value and modified date are columns.

    Any suggestions would be helpful.

    select *
    from (
      select id
           , lag(value) over(partition by id order by dt) as old_value
           , value as new_value
           , dt as changed_date
      from test
    )
    where old_value is not null ;
    
  • Help request NULLIF

    Hi all

    I wrote the request to show that if the sal & comm are same the result should display 'same' thing below, it should display "diff".

    Select nullif (sal, comm), ename

    WCP

    where is nullif (sal, comm) =: nullif (sal, comm)

    then dbms_output.put_line ('same')

    on the other

    dbms_output.put_line ('diff')

    /

    But I get the mentioned error below

    SP2-0552: Bind "NULLIF" undeclared variable.

    Help is kindly solve its appearance like why and what needs to be done.

    Thank you...

    Others have mentioned your errors of syntax and other ways to do the task, but nobody gave the reason for the specific error that you got.  Here it is:

    Select nullif (sal, comm), ename
    WCP
    where if nullif (sal, comm) =: nullif (sal, comm)
    then dbms_output.put_line ('same')
    on the other
    dbms_output.put_line ('diff')

    The equality in SQL and PL/SQL operator is = and in PL/SQL assignment operator : =. There is no =: operator anywhere, if the compiler sees the: nullif as a variable binding.

    John

  • Select the request match the columns diagonally

    Hello

    Here are the instructions struncture and table insert
    create table emp_trans values (empno number , emptran_no number, prev_amount number, current_amount number)
    
    insert into emp_trans values(102,109,0,20);
    insert into emp_trans values(102,119,10,20);
    insert into emp_trans values(102,129,20,30);
    insert into emp_trans values(102,139,30,0);
    
    insert into emp_trans  values(201,101,0,20);
    insert into emp_trans values(201,110,20,30);
    insert into emp_trans values(201,120,0,30);
    insert into emp_trans values(201,130,30,20);
    insert into emp_trans values(201,140,0,20);
    In the chart, we see some mappings as follows

    Data based empno.
    We have 2 employees with empno 201 and 102. Each empno has different emptrans_no. Are not necessarily in a sequence.
    We have to select the Recordset where prev_amount column matches the values in column current_amount for
    the previous record for each individual empno.

    until the next basic select statement can be considered
    select * from emp_trans  order by empno , emptran_no
    for ex:

    the column values of prev_amount of emptran_no 129 EMP No 102 with values of 20 matches with the column of current_amount have 20
    with emptran_no 119.

    empno 201 with emptran_no 110, we can see the column of prev_amount having the value put 20 mapped to havig 20 current_account column values
    of emptran_no previous 101 for the same 201 empno.

    something like we need to see the values of mathced diagonally.

    Any help on this request, most welcome.

    Kind regards

    Hello

    Sri says:
    Hello

    Here are the instructions struncture and table insert

    create table emp_trans values (empno number , emptran_no number, prev_amount number, current_amount number) ...
    

    Thanks for posting the CREATE TABLE and INSERT. Please test 9and, if necessary, correct) them before posting. You do not want the word 'values' above.

    In the chart, we see some mappings as follows

    Data based empno.
    We have 2 employees with empno 201 and 102. Each empno has different emptrans_no. Are not necessarily in a sequence.
    We have to select the Recordset where prev_amount column matches the values in column current_amount for
    the previous record for each individual empno.

    Means "the previous record? Is the line with the same empno and the next emptran_no below? The combination (empno, emptran_no) is unique?
    >

    until the next basic select statement can be considered

    select * from emp_trans  order by empno , emptran_no
    

    for ex:

    the column values of prev_amount of emptran_no 129 EMP No 102 with values of 20 matches with the column of current_amount have 20
    with emptran_no 119.

    empno 201 with emptran_no 110, we can see the column of prev_amount having the value put 20 mapped to havig 20 current_account column values
    of emptran_no previous 101 for the same 201 empno.

    something like we need to see the values of mathced diagonally.

    Any help on this request, most welcome.

    Kind regards

    Always show the desired results from the given sample data. It is fine to describe the results, but describe them after (not instead of) displaying.
    Is that what you want?

    `    EMPNO EMPTRAN_NO PREV_AMOUNT CURRENT_AMOUNT
    ---------- ---------- ----------- --------------
           102        129          20             30
           102        139          30              0
           201        110          20             30
           201        130          30             20
    

    Here's a way to get these results:

    WITH   got_prev_current_amount     AS
    (
         SELECT     empno, emptran_no, prev_amount, current_amount
         ,     LAG (current_amount) OVER ( PARTITION BY  empno
                                          ORDER BY         emptran_no
                               )        AS prev_current_amount
         FROM    emp_trans
    )
    SELECT       empno, emptran_no, prev_amount, current_amount
    FROM       got_prev_current_amount
    WHERE       prev_amount     = prev_current_amount
    ORDER BY  empno, emptran_no
    ;
    
  • Help request Service!

    In a Service request, I created a field of type is TimeStamp. The name of this field is "Suspension to start."
    I would like the default value in this field is the exact time of the time when I change the status of the demand for services and the State is monitoring.
    When the status of this service request stands in assisted, the value of the field ('Suspension start') must be null, when the State becomes assisted, he is practically should be valued with the time of the change.


    I wrote in the service of the default:

    IIf ([< status >] =' attesa', Timestamp (), 'Null')

    but it does not work, how do I do?


    later as I do to develop a new field (end Suspension) with the exact time when the demand for services status changes to in a attended a different value.

    Help me, please!
    Thanks Vale.

    Hello!

    When you have selected the status field in the field list, simply click on the link to the right of the drop-down list field. It will allow you to select the status you need and it will add LookupValue() in your state.

    Try and test it and tell me...

    Max

  • Why is my help requests being deleted?

    3-4 of my requests for help last week disappeared.

    I'm still waiting for assistance.

    My messages were respectful at all times.

    Why is this done?

    Spitfire,

    Maybe they were duplicates, as these two?

    Results of terminal script below for frozen, then slow cursor

    Frozen cursor MacBook Pro 13 "w updates

  • Cannot right click Windows 7 Explorer of files to generate the copy of the file names in a Notepad or Excel-compatible file. HELP REQUESTED!

    I struggled for several hours to restore the service right click that I used to have XP to Windows 7.  I need to save lists of file names such as displayed in the file Explorer. Allowing you to right-click and save files in Notepad. This option has been removed in Windows 7 and anything put in place to restore it.

    I have lists of items in the inventory and need to copy and paste the image corresponding to a transfer sheet to allow the server names to match images in article SKU.  The file names are long and typing is a complete waste of time.

    I used to be able to find them in the Windows Explorer, right-click on the directory and generate a txt file that I could open in Notepad or Excel.  -Easy.  Now right-click only allows an export in an uneditable image in ONE NOTE. This is useless for me. I can't do anything with an image file - I need the editable data.

    Is there a solution?  I need only the file name and extension, not the full path, in a text or spreadsheet document propagation.

    I had used the Microsoft solution to install their dose without knowing the final format was a NOTE image file format and not a simple txt file. I try now too write the batch file:

    %windir%\Printdir.bat

    or edit it in order to keep the file in Notepad and do not make the final conversion into a single Note.

    The problem is that the fix from Microsoft, designed to fix this problem, has placed the conversion file in the root directory and it cannot be overwritten.  I refused the possibility to delete, edit or write the file due to the requirements of administrative privilege mandated by the security of Windows 7 too much.

    So if anyone has a solution to every problem - that would help - I am very tired and frustrated and not happy with Microsoft.  Their zealous concern with security made their unnecessary programs for me and have further discouraged me to convert to the windows 10. frustrations and nightmares are waiting for me there I can't imagine.  What I really want to do at this point is to go back to XP.

    He ate five hours of my day. I don't have the time to fight like that. I am trying to be productive, but all I got are monumental technical walls and roadblocks - often designed into the system. Frustrating doesn't begin to describe it.

    Found a solution on a Web site:

    http://www.watchingthenet.com/how-to-print-a-directory-tree-from-Windows-Explorer.html

    They said it was for VISTA, but worked for me under Windows 7. You will need to use Notepad to the command prompt and select run as administrator to save the file in the root directory.

    Thanks for the help.

    Cheers.

  • Help request deleted blackBerry smartphones! I want to go back!

    I accidentally deleted the request for help while trying to remove a third-party application. I was surprised that a, I fact and two, let me not! How do I get it without having to reload all the software completely (and lose all my other apps)?

    Open your Desktop Manager > application loader, run it and CHECK help load.

    If nothing is present in the application loader, you need to charge your current device OS on your PC.

  • Help the integration of Animation

    Hi thanks for looking at my question.

    I created a marquee of simple animation to animate CC.  I get edge from adobe that I know well.  Animate not so much.  My problem was not animate but to insert into Dreamweaver.  I have it here, but I can't apply CSS.

    the site is www.pineywoodsfarming.com

    If you go into manager wanted you can see Center trying to get.  I did this on the edge.  try to learn to animate since this is where adobe seems to take place.  waiting on Lynda.com to do a program about it so I can learn, but they take their sweet time.

    I don't know if I'm not selecting right or what, but I can't seem to get it to the Center.  Aware that car right and left on my margins if I choose the correct selector it will center but for some reason, nothing I've tried works.

    I tried to set on the page in the section style (not published online)

    {#EdgeID}

    left margin: auto;

    margin-right: auto;

    Overflow-x: hidden;

    Overflow-y: hidden;

    }

    And who does not either.

    I also have the problem of this bar at the bottom.  I can't get rid of it yet.

    Help is appreciated.

    Thank you

    strange thing if you go to link managers then back home it seems to be old text scrolling.  not sure if cache problem or I have to solve that.  but who can show you what I'll do.  and I know that the animation and transition is not so great.  I have a lot of work to animate in CC to catch up.

    IMO, animate is way overkill for a slide show.  jQuery is much better suited for this.

    Take a look at the Cycle2 or Wow Slider to the carousel of Bootstrap.  Best results, more options, less the size of the file.

    "Bootstrap" demo (view source to see the code)

    Nancy O.

  • Help request of customer orders

    Hello!

    I'm stuck and I'm a little confused about what to do.

    I did a query that displays sales order data, the query is:

    "

    Select

    OHA.order_number "Order number"

    OHA.ordered_date "Order date"

    OHA.cust_po_number "Number"

    Ott.Name "Order Type"

    OLA.line_number "Line number"

    MSI. Segment1 "Item Code",

    MSI. 'The item name, description

    -wdd.lot_number "LOT number"

    OLA.ordered_quantity "quantity."

    OLA.order_quantity_uom "UOM ordered."

    OHA.transactional_curr_code "currency."

    OLA.unit_selling_price 'unit sales price. "

    (ola.ordered_quantity * ola.unit_selling_price) "Sale price of line."

    OLA.shipping_quantity 'quantity shipped. "

    OLA.shipping_quantity_uom "UOM Quantity Shipped."

    (nvl(ola.shipping_quantity,0) * ola.unit_selling_price) "Delivered price",.

    cases where oha.transactional_curr_code = 'HUF' THEN (nvl(ola.shipping_quantity,0) * ola.unit_selling_price) other (nvl (ola.shipping_quantity, 0) * ola.unit_selling_price * ATCM.) End EXCHANGE_RATE) "prize shipped in HUF.

    OLA. ACTUAL_SHIPMENT_DATE "Delivery Date"

    extract (YEAR OF OLA. ACTUAL_SHIPMENT_DATE) "Shipped year."

    extract (MONTH OF OLA. ACTUAL_SHIPMENT_DATE) "Shipped months."

    extract (DAY OF OLA. ACTUAL_SHIPMENT_DATE) "Shipped day."

    OL. Meaning "order status."

    HCA.account_number 'Cardcode. "

    bill_p.party_name 'Cardname. "

    DECODE (bill_loc.city,

    NULL, NULL,

    bill_loc. City | ', '

    )

    || DECODE (bill_loc.state,

    NULL, bill_loc.province | ', ',

    bill_loc. State | ', '

    )

    || DECODE (bill_loc.postal_code,

    NULL, NULL,

    bill_loc.Postal_Code | ', '

    )

    || DECODE (bill_loc.country, NULL, NULL, bill_loc.country) "Delivery address"

    bill_loc. Address1 'Expedition street. "

    ship_loc. "Shipping city," city

    ship_loc. Indicative "Expedition", country

    FT.territory_short_name "country of dispatch",.

    (select name

    of ra_salesreps_all

    where salesrep_id = oha.salesrep_id

    and org_id = oha.org_id) 'name of the sales person.

    of oe_order_headers_all oha.

    ola oe_order_lines_all,

    oe_transaction_types_tl ott,

    MSI mtl_system_items_b,

    hz_cust_site_uses_all bill_su,

    hz_party_sites bill_ps,

    hz_locations bill_loc,

    hz_cust_acct_sites_all bill_cas,

    hz_cust_accounts bill_ca,

    hz_parties bill_p,

    hz_cust_site_uses_all ship_su,

    hz_party_sites ship_ps,

    hz_locations ship_loc,

    hz_cust_acct_sites_all ship_cas,

    -wsh_deliverables_v WD

    fnd_territories_tl ft,

    oe_lookups ol,

    hz_cust_accounts_all AOB,

    ra_customer_trx_all ATCM,

    ra_customer_trx_lines_all rctla

    -wsh_delivery_details JMD

    where oha.header_id = ola.header_id

    and bill_p.party_id = hca.party_id

    - and wdd.source_header_id = ola.header_id

    - and wdd.source_line_id = ola.line_id

    and oha. ORDER_TYPE_ID = ott.transaction_type_id

    and ott.language = userenv ('LANG')

    and ola.inventory_item_id = msi.inventory_item_id

    and ola.ship_from_org_id = msi.organization_id

    and oha.invoice_to_org_id = bill_su.site_use_id (+)

    and bill_su.cust_acct_site_id = bill_cas.cust_acct_site_id (+)

    and bill_cas.party_site_id = bill_ps.party_site_id (+)

    and bill_loc.location_id (+) = bill_ps.location_id

    and bill_cas.cust_account_id = bill_ca.cust_account_id

    and bill_ca.party_id = bill_p.party_id

    and oha.ship_to_org_id = ship_su.site_use_id (+)

    and ship_su.cust_acct_site_id = ship_cas.cust_acct_site_id (+)

    and ship_cas.party_site_id = ship_ps.party_site_id (+)

    and ship_loc.location_id (+) = ship_ps.location_id

    and ship_loc.country = ft.territory_code

    and ft.language = userenv ('LANG')

    and ol.lookup_type = 'FLOW_STATUS. '

    and ol.lookup_code = oha.flow_status_code

    and ola.shipping_quantity IS NOT NULL

    AND rcta.customer_trx_id = rctla.customer_trx_id

    AND rctla.interface_line_attribute6 = TO_CHAR (ola.line_id)

    AND rctla.interface_line_attribute1 = TO_CHAR (oha.order_number)

    - and oha.order_number = 1000914

    "

    The query works perfectly except one case.

    If I have sous-lignées, non-conventional lines (see attachments) in this case the query display only the first value of sub-line.

    Also if I connect wsh_deliverables_v tables for LOT numbers, the lines will be multiple and I don't know why

    Thanks for your help in advance,

    Zsolt

    I found the solution. If someone else stuck, here is the solution:

    In where condition change this line:

    AND rctla.interface_line_attribute6 = TO_CHAR (ola.line_id)

    to do this:

    AND (rctla.interface_line_attribute6 = TO_CHAR (ola.line_id) or rctla.interface_line_attribute6 = TO_CHAR (ola.split_from_line_id))
  • Help requests on max and min

    HI friends,

    referring to the sample data below, can you please help me GET the supplied output.

    WITH tt (ID, OS, prev_os, START_DT, NEXT_DT) AS

    (SELECT 1, 'a', TO_DATE (September 10, 2014 00:00:00 ',' DD/MM/YYYY HH24:MI:SS'), (NULL), TO_DATE('09/29/2014 00:00:00', 'MM/DD/YYYY HH24:MI:SS') OF double UNION ALL to_char)

    SELECT 1, 'a', TO_DATE (30 September 2014 00:00:00 ',' DD/MM/YYYY HH24:MI:SS'), 'a', TO_DATE('10/09/2014 00:00:00', 'MM/DD/YYYY HH24:MI:SS') FROM dual UNION ALL

    SELECT 1, 'b', TO_DATE (October 10, 2014 00:00:00 ',' DD/MM/YYYY HH24:MI:SS'), 'a', TO_DATE('10/19/2014 00:00:00', 'MM/DD/YYYY HH24:MI:SS') FROM dual UNION ALL

    SELECT 1, 'a', TO_DATE (20 October 2014 00:00:00 ',' DD/MM/YYYY HH24:MI:SS'), 'b', NULL FROM dual)

    SELECT * FROM tt

    1one10/09/201429/09/2014
    1one30/09/2014one09/10/2014
    1b10/10/2014one19/10/2014
    1one20/10/2014b

    Out put:

    ID os strt_dt end_dt
    1one
    10/09/2014
    09/10/2014
    1b
    10/10/2014
    19/10/2014
    1one
    20/10/2014

    Hello

    866088 wrote:

    OKI,

    I'm currently implementing scd2

    is there are several consecutive admissions for an id, operating system after a sort on the start date, then I should have only one entry for this id, os with min (start_dt) and max (end_dt)

    What is scd2?

    There are several different things that might mean by "consecutive".  What do you mean exactly?

    Maybe you want something like this:

    WITH got_grp_id AS

    (

    SELECT id, os, start_dt, next_dt

    ROW_NUMBER () OVER (PARTITION BY id ORDER BY start_dt)

    -ROW_NUMBER () OVER (PARTITION BY id, os ORDER BY start_dt) AS grp_id

    TT

    )

    SELECT id, os

    MIN (start_dt) AS min_start_dt

    MAX (next_dt) AS max_next_dt

    OF got_grp_id

    GROUP BY id, the os, the grp_id

    ORDER BY id, min_start_dt

    ;

    Output:

    ID O MIN_START_D MAX_NEXT_DT

    ---------- - ----------- -----------

    1 one 10-Sep-2014, October 9, 2014

    1 b 10 October 2014 October 19, 2014

    1 to 20 October 2014

    For an explanation of the technique of Difference sets used here, see

    Analytical question lag and lead

    or

    Re: Ranking of queries

  • Sequence by select Help please:

    First of all, I'm rather at this new and need help please.

    I created the following sequence:

    CREATE SEQUENCES SQ_CASE_NUMB

    MINVALUE 1

    INCREMENT BY 1

    START WITH 1

    And from this sequence select it below:

    SELECT TO_CHAR (SQ_CASE_NUMB. NEXTVAL)

    | | To_char (SYSDATE, "fm/MM/yy")

    Case_NUMB

    OF THE DOUBLE

    Result:

    Case_NUMB

    08/01/14

    08/02/14

    08/03/14

    Can I combine the sequence 'create' and 'select '? Or should I create a function?

    What is the best option please?

    It depends on what you're trying to reach.  What you use the sequence for?  Primary key?  Experiment?  fun?

    Best option can be answered only if you provide the object...

    BTW - the select query above works, but it does not mean that you should use...  The best thing to do (if you use it as a primary key) is to create a trigger like this:

    create or replace

    TRIGGER "insert name here".

    BEFORE INSERT ON table_name

    FOR EACH LINE

    BEGIN

    SELECT sequence_name. NEXTVAL INTO: DOUBLE NEW.pkcolumn_name;

    END;

Maybe you are looking for