Minimum in and maximum out

In a table i have the following columns , all were varchar2 column and sample data
workdate 10/22/2009
in1 7:48:28 AM
in2 12:46:01 PM
in3 null
out1 12:14:30 PM
out2 null
ou3 null
I need a query which retrieves minimum in and maximum out in DD-MON-YYYY HH24:MI:SS format.
if any of the in columns is null mimimum in should be null
if any of the out columns is null maximum out should be null
if minimum in is null,then its value should be equivalent to maximum out
if minimum out is null,then its value should be equivalent to minimum in
if workdate is null both minimum in and maximum out should be null.
Please help gurus...

Andreas Weiden wrote:
To make the LEAST and GREATEST-function work as desired, you may have to convert your varchar2 to date-vars using TO_DATEFirst of all, CASE for INs/OUTs is overcomplication. LEAST/GREATEST produces null if one of the items is null. However, since OP uses AM/PM notation you must+* (not may) convert to date. Otherwise:
SQL> WITH THETABLE AS (SELECT '10/22/2009' WORKDATE,
  2                           '7:48:28 AM' IN1,
  3                           '12:46:01 PM' IN2,
  4                           NULL IN3,
  5                          '12:14:30 PM' OUT1,
  6                           NULL          OUT2,
  7                           NULL          OUT3
  8                      FROM DUAL
  9                    UNION ALL
10                    SELECT '10/22/2009' WORKDATE,
11                           '7:48:28 AM' IN1,
12                           '12:46:01 PM' IN2,
13                           '12:46:02 PM' IN3,
14                           '12:14:30 PM' OUT1,
15                           NULL          OUT2,
16                           NULL          OUT3
17                      FROM DUAL
18                    UNION ALL
19                    SELECT '10/22/2009' WORKDATE,
20                           '7:48:28 AM' IN1,
21                           '2:46:01 PM' IN2,
22                           '2:46:02 PM' IN3,
23                           '9:14:30 AM' OUT1,
24                           '2:14:32 PM' OUT2,
25                           '3:14:34 PM' OUT3
26                      FROM DUAL
27                   )
28  SELECT  IN1,IN2,IN3,LEAST(IN1, IN2, IN3) LEAST_IN,
29          OUT1,OUT2,OUT3,GREATEST(OUT1, OUT2, OUT3) GREATEST_OUT
30    FROM THETABLE
31  /
IN1        IN2         IN3         LEAST_IN    OUT1        OUT2       OUT3       GREATEST_OU
7:48:28 AM 12:46:01 PM                         12:14:30 PM
7:48:28 AM 12:46:01 PM 12:46:02 PM 12:46:01 PM 12:14:30 PM
7:48:28 AM 2:46:01 PM  2:46:02 PM  2:46:01 PM  9:14:30 AM  2:14:32 PM 3:14:34 PM 9:14:30 AM
SQL> SY.

Similar Messages

  • What is the impact, if I mainatin minimum salary and maximum salary as zero

    Hi,
    While maintaing reference salary, we will mainatin minimum and maximum salary. Based on these values, position within salary ranges will be calculated and same will be displayed at portal under compensation details. What is the imapct, if i maintian minimum salary and maximum salary as zero in refrence salary. I will be maintaining some value (let say 53.897) as reference salary.
    Regards
    Siri

    Hi,
    Min and Max sal is only shown as information. It will not have any impact.
    with regards,
    S.Karthik

  • Minimum and maximum quantity

    Dear All,
    Can any one help me by telling that is there any way system automatically defining minimum quantity and maximum quantity, i know that if we define it in the material master then while MRP run it will pick up if it is on minimum level i wanna know is there any way that system suggest itself minimum and maximum on base of history of transactions.
    reagrds,
    Qasim Malik

    How we can maintain the minimum / maximum level in the material master, is there any report to find out the minimum / maximum level of the material.
    Regards
    Kashif

  • How to design and list out in ascending order from minimum to maximum with 6 inputs

    hi,
    How to design and list out in ascending order from minimum to maximum with 6 inputs in Labview? 
    This is easy to write it in C++, but not in Labview,may be I am new to Labview. i manage to get the 1st and the 6th after compared, but i cant get 2nd, 3rd, 4th, 5th.
    and can i write c++ language in Labview VI ?
    thanks.
    Solved!
    Go to Solution.
    Attachments:
    24-1-2012 display 4.vi ‏7 KB

    Try this:
    Beginner? Try LabVIEW Basics
    Sharing bits of code? Try Snippets or LAVA Code Capture Tool
    Have you tried Quick Drop?, Visit QD Community.

  • Change Datepicker Minimum and Maximum Value

    Hi everyone,
    I have a date item with minimum and maximum dates from 2 hidden items.
    The problem is that when i change the value of thos 2 hidden items , the minimum and maximum dates in my datepicker doesn't change.
    I've tried refreshing the date item but it still doesn't work.
    Kind Regards,
    Cearnau Dan
    APEX 4.0.1

    Geert,
    Thanks for your reply. I tried making the hidden item to not protected as you suggested. Changing it to not protected had no effect on setting the Min/Max values of the date picker.
    After reading the following thread I have had some success using javascript to the min/max option of the date picker.
    Re: Dynamic Action On Date Picker
    Documentation on jquery date picker.
    http://jqueryui.com/demos/datepicker/
    Thanks,
    Todd

  • How to maintain minimum price limit and maximum price limit for a condition

    Hello Gurus,
    Goodmorning,
    How to set minimum price  limit and maximum price limit for a pricing condition type  where we will do this ?, is it possible to set in VK11 ?
    Note- I   can see  minimum and maximum setting in condition type  pricing - in  SPRO but  not seen anything in VK11 condition record maintaince  . so how to maintain in condition record( VK11-Minimum limit  price and Max limit  price )
    Looking for your inputs 
    Thanks in advance
    Regards
    Venkat

    hi,
    in VK12
    select the condition record - goto blue ladder icon
    there you can maintain scales
    like lower limit and upper limit.
    balajia

  • How to set minimum and maximum X scale in the XY graph if i have a X scale time format ?

    Hi,
    i choose in the picture enclosed, a time format for the X scale of the XY Graph.
    The problem is that i am not able to set the minimum and maximum of the X scale: In fact the property nodes of the minimum and maxinum X scales ask for  double as input.
    But i need to set my minimum and maximum X scale to be a time (because I already set the X scale format to a time)
    Could u help me please ?
    Samer,
    Attachments:
    scale.JPG ‏8 KB

    please i have another problem:
    i put the XY Graph in a while loop with maximum and minimum Xscale as property nodes inputs.
    The problem is that when i make a zoom  i can just see the zoom for a little while and then (because of the while loop) the Xscale is updated.
    is there a method so that the Xscale be updated just when i change its value ?
    or Could u tell me how could i zoom properly ?
    Samer,
    Attachments:
    zoom.JPG ‏11 KB

  • Minimum and maximum quantities in sales order

    Hello friends,
    Can anyone tell me how to maintain minimum quantity in sales order, (Not Minimum order quantity of material master) as only maximum (target) quantity is maintainable in sales order at Item level? So after this development in sales order, one can enter two quantities (minimum and maximum) so that sale can be done between this quantity range.
    I know this is not possible without exits or developments, but please tell if someone has came across the same scenario which exits used by you.
    Thanks in advance
    Warm regards
    Amit

    Min/Max quantity by sales order line items, but not by material?
    You can have your abapper code the Additional Data B screen user exits at the line item level.  You will add two quantity fields - min qty and max qty.  You will also have to code USEREXIT_CHECK_VBAP to enforce the rule that order quantity is between the limits.

  • Rounding Value,Minimum Lot Size and Maximum Lot Siz parameters

    Hello Gurus,
           Please explain me the what is the use of the parameter Rounding Value
    ,Minimum Lot Size and Maximum Lot Size parameters in the product master and how does it in impact during the Heuristic Run?
    Thanks.

    Rounding value is the incremental quantities in which the order can be produced/procured. Eg. if orders are possible with quantities 40,60, 80, 100 etc..then rounding value is 20.
    Min lot size is the minimum quanity in which order can be produced eg. 40 in above example
    Max lot size is the maximum quanitity in which the order can be produced/procured. eg. 100 in our example
    Impact on Heuristic run: heuristics takes all the above parameter to plan supply order. eg. if requirement is 55, it will supply plan for 60. If requirement is 120, it will produce two orders - one for 100 and the other for 20. if the reuqirement is 10, the order size will be 40.
    Hope this helps.

  • Minimum and maximum allowed order qty

    we want to configure minimum and maximum allowed order qty in STO for  our internal stock transfers.
    plz suggest the config steps to be follow for deploying this activity.

    Hi
    I think this requirment is for  Retail industry, like stock transfer between stores, clarify
    Its not possible in standard I hope, because its purchase order related, check with ABAPer you can implement BAPI and control this setting error message if quantity is differ from Min and max you entered. system should not save the STO if quantity is mismatch, you can achive this through User exist or BAPI.
    regard
    Satish

  • Minimum and maximum order qty

    we want to configure minimum and maximum allowed order qty in STO for our internal stock transfers.
    plz suggest the config steps to be follow for deploying this activity.

    My requirement is for intercompany stock transfers scenario.
    assume that there are plants 101 and 102, when ever STO through ME21N is occuring system should cross check with minimum order qty for given materials failure of which system should give error message, same way from supplying plant system should check minimum delivery qty for receiving plant failure of which system should give error message and should not allow for outbound delivery.
    suggest the process need to configure.

  • Setting the Minimum and Maximum Y Axis Points

    Hi,
    I have an Application where I need to plot the charts using Time-Scatter Graph .
    I am using 2 Y-Axis.
    But I am unable to dynamically set the Minimum and Maximum y-axis points through code.
    Currently I have set the Minimum and Maximum points for the Y Axis in BG (Business Graphics) Design Time.
    Please suggest if we can set the Min & Max values through code as it is very cumbersome to manually set the Min and Max Values for say around 400 odd charts.
    We are unable to set the Chart Title too dynamically.
    Thanking in advance,
    Poojith

    Any Experts here.. Please help

  • Minimum Order Quantity and Maximum Order Quantity

    Hi Gurus
    Can u fix the Minimum and Manximum Order Quantity for a Particular Sales Order.
    if i enter the Minimum Order Quantity in Material Master Record (Sale Org--1 tab), it is working.  But it is happening with all the order types.
    My requirement is i need this to be happend with only a particular Order type YOR and not with ZOR.
    Mininum Order Qty        - 5 ea, and
    Maximum Order Qty      - 10 ea.
    so that for this order type YOR for any material the order qty for a line item cannot be less than 5 qty and more than 10 qty
    is there any way to do this,
    if it is possible by creating an User Exit, please give me Step-by-Step solution.
    I do now know how to Create USER EXITS
    babu rao

    HI BABUR,
    try to do it in userexit , first in a test system.
    you can try userexit MV45AFZZ.
    SE38 and programm name MV45AFZZ.
    there you can see fields of vbak, vbap or xvbak , xvbap.
    the last two are structures.

  • Minimum and maximum memory for starting OSB domain.

    Hi,
       How much minimum/maximum default of memory do we need to run welogic domain for OSB ? I know we can use java comand with Xmx and Xms to set amount of memory to run domain. I want to know minimum and maximum default when we start domain.
    Many thanks.

    Dear All,
    I have attach a VI. Bascially, i want to control the maximum and minimum points using the control by keying in the timestamp date and time. How do i do that/
    Thanks!
    Attachments:
    test5.txt ‏1 KB
    timestamp.vi ‏14 KB

  • MINIMUM AND MAXIMUM LEVAL OF MATERIAL

    HI
       EXPERT
    Can you everybody tell me standard report for maximum and minimum leval of material or any customization
    Thanks&Regards
      vijay

    hi,
    there are 8 levels in Sap
    In materail master in the MRP1 Tab under Lot Size Data you have two options
    Minimum Lot size and maximum lot size These two options would help you in determining the lot size when Placing a PO
    setting the values in here will create a PO for minimum lot size Qty even if you give lessthan the qty specified in that field
    In the same Material master Under Purchasing tab you have a check box Automatic PO flag this option as well
    It Defines that purchase orders are generated automatically when purchase requsisitions are converted into purchase orders.
    At the same time in the master record for the vendor with whom the material is ordered, the field "Automatic purchase order" must be flagged in the control data for the purchasing data.
    Now PO's are generated automatically with the specified minimum order value
    How ever this scenarion would be possible only if we are running MRP and finding material requirement and generating PR & PO automatically
    I doubt it would work if you are creating PO manually
    If found helpful, reward me.
    Thanks & regards
    Swathi

Maybe you are looking for

  • IOS7 calendar

    When I view calendar in YEAR format, it doesn't highlight the days that have an appt. scheduled. Once I upgraded, this option disappeared. Is there a format change I can make? It was helpful to see whole Year With highlighted days.

  • I'm having an issue with Preview shutting down on a  search command

    here is the code that I was given.  Please help? Process:         Preview [7228] Path:            /Applications/Preview.app/Contents/MacOS/Preview Identifier:      com.apple.Preview Version:         7.0 (826) Build Info:      Preview-826000000000000~

  • Problems with add() and remove() in my Doubly Circular Linkedlist code

    I have been working on this code for 6 hours and some how it won't remove correctly when the list has 0,2,4 elements. It will attempt to remove element at index 0 but actually removed 4. I thought it was the reference problem at first, so i did somet

  • Urgent : Tracing required Datasource from a report

    Hi, I have to implement SD in BI, there is a TCODE given to me by the client that outputs a report (as per there requierment), Using the TCODE i have to activate the datasources and to transfer the data. The fields on the selection screen i am able t

  • Using the "Plan a meeting" function in Outlook

    Hi all When I set up a meeting on my iPhone and transfer the details to my work PC, it shows up in full in my calendar, but when I go to the "plan a meeting" function, it has disappeared from there! This function is really important to me as others u