Help with a ROUND function

Hi everyone, can someone please help me with a function to use here please. I have a nine digit number e,g (000046650 and 024063870). I would like to convert this to 4 digits before the comma and 5 digits after the comma. So it must be something like this (0000,46650 and 0240,63870). I thought I could easily do this with a ROUND function, but it doesn't work. Could somebody please help by telling me what I'm missing?
Thank you all for your help.

Hi,
I must be missing something, but why don't you just divide by 10000 ?Scott@my11g SQL>with d as (
  2  select 000046650 n from dual
  3  union all
  4  select 024063870 from dual
  5  )
  6  select n/10000 from d ;
   N/10000
     4.665
  2406.387You can then use a to_char with fmt to format it with zero padding :Scott@my11g SQL>with d as (
  2  select 000046650 n from dual
  3  union all
  4  select 024063870 from dual
  5  )
  6  select to_char(n/10000,'0000.00000') nn from d ;
NN
0004.66500
2406.38700

Similar Messages

  • Problem with the round function using Date

    Hi,
    I have a problem with round function for Date. The input is the four digit year which was picked out from say SYSDATE.
    In these scenarios the original value should be rounded up and should get the output as shown under rounded column.
    Scenario1
    Original Rounded
    2020 ---> 2020
    2021 ---> 2020
    2022 ---> 2020
    2023 ---> 2020
    2024 ---> 2020
    2025 ---> 2025
    2026 ---> 2025
    Scenario2
    Original Rounded
    2020 ---> 2020
    2021 ---> 2025
    2022 ---> 2025
    2023 ---> 2025
    2024 ---> 2025
    2025 ---> 2030
    2026 ---> 2030
    Scenario3
    Original Rounded
    2020 ---> 2020
    2021 ---> 2020
    2022 ---> 2020
    2023 ---> 2025
    2024 ---> 2025
    2025 ---> 2025
    2026 ---> 2025
    Can anyone help with this....Urgent Please
    Thanx for your time

    1.
    SQL> select n,n-mod(n,5) rnd from test;
             N        RND
          2020       2020
          2021       2020
          2022       2020
          2023       2020
          2024       2020
          2025       2025
          2026       2025
    2.
    SQL> select n,n+(case when mod(n,10) = 0 then 0
      2                   when mod(n,10) < 5 then 5-mod(n,5)
      3                   else 10-mod(n,10)
      4              end) rnd
      5  from test;
             N        RND
          2020       2020
          2021       2025
          2022       2025
          2023       2025
          2024       2025
          2025       2030
          2026       2030
    7 rows selected.
    3.
    SQL> select n,n+(case when mod(n,10) < 3 then mod(n,10)*-1
      2                   when mod(n,10) < 8 then 5-mod(n,10)
      3                   else 10-mod(n,10)
      4              end) rnd
      5  from test;
             N        RND
          2020       2020
          2021       2020
          2022       2020
          2023       2025
          2024       2025
          2025       2025
          2026       2025
          2027       2025
          2028       2030
          2029       2030
          2030       2030
    11 rows selected.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           

  • Need some help with the Table Function Operator

    I'm on OWB 10gR2 for Sun/Solaris 10 going against some 10gR2 DB's...
    I've been searching up and down trying to figure out how to make OWB use a Table Function (TF) which will JOIN with another table; allowing a column of the joined table to be a parameter in to the TF. I can't seem to get it to work. I'm able to get this to work in regular SQL, though. Here's the setup:
    -- Source Table:
    DROP TABLE "ZZZ_ROOM_MASTER_EX";
    CREATE TABLE "ZZZ_ROOM_MASTER_EX"
    ( "ID" NUMBER(8,0),
    "ROOM_NUMBER" VARCHAR2(200),
    "FEATURES" VARCHAR2(4000)
    -- Example Data:
    Insert into ZZZ_ROOM_MASTER_EX (ID,ROOM_NUMBER,FEATURES) values (1,'Room 1',null);
    Insert into ZZZ_ROOM_MASTER_EX (ID,ROOM_NUMBER,FEATURES) values (2,'Room 2',null);
    Insert into ZZZ_ROOM_MASTER_EX (ID,ROOM_NUMBER,FEATURES) values (3,'Room 3','1,1;2,3;');
    Insert into ZZZ_ROOM_MASTER_EX (ID,ROOM_NUMBER,FEATURES) values (4,'Room 4','5,2;5,4;');
    Insert into ZZZ_ROOM_MASTER_EX (ID,ROOM_NUMBER,FEATURES) values (5,'Room 5',' ');
    -- Destination Table:
    DROP TABLE "ZZZ_ROOM_FEATURES_EX";
    CREATE TABLE "ZZZ_ROOM_FEATURES_EX"
    ( "ROOM_NUMBER" VARCHAR2(200),
    "FEATUREID" NUMBER(8,0),
    "QUANTITY" NUMBER(8,0)
    -- Types for output table:
    CREATE OR REPLACE TYPE FK_Row_EX AS OBJECT
    ID NUMBER(8,0),
    QUANTITY NUMBER(8,0)
    CREATE OR REPLACE TYPE FK_Table_EX AS TABLE OF FK_Row_EX;
    -- Package Dec:
    CREATE OR REPLACE
    PACKAGE ZZZ_SANDBOX_EX IS
    FUNCTION UNFK(inputString VARCHAR2) RETURN FK_Table_EX;
    END ZZZ_SANDBOX_EX;
    -- Package Body:
    CREATE OR REPLACE
    PACKAGE BODY ZZZ_SANDBOX_EX IS
    FUNCTION UNFK(inputString VARCHAR2) RETURN FK_Table_EX
    AS
    RETURN_VALUE FK_Table_EX := FK_Table_EX();
    i NUMBER(8,0) := 0;
    BEGIN
    -- TODO: Put some real code in here that will actually read the
    -- input string, parse it out, and put data in to RETURN_VALUE
    WHILE(i < 3) LOOP
    RETURN_VALUE.EXTEND;
    RETURN_VALUE(RETURN_VALUE.LAST) := FK_Row_EX(4, 5);
    i := i + 1;
    END LOOP;
    RETURN RETURN_VALUE;
    END UNFK;
    END ZZZ_SANDBOX_EX;
    I've got a source system built by lazy DBA's and app developers who decided to store foreign keys for many-to-many relationships as delimited structures in driving tables. I need to build a generic table function to parse this data and return it as an actual table. In my example code, I don't actually have the parsing part written yet (I need to see how many different formats the source system uses first) so I just threw in some stub code to generate a few rows of 4's and 5's to return.
    I can get the data from my source table to my destination table using the following SQL statement:
    -- from source table joined with table function
    INSERT INTO ZZZ_ROOM_FEATURES_EX(
    ROOM_NUMBER,
    FEATUREID,
    QUANTITY)
    SELECT
    ZZZ_ROOM_MASTER_EX.ROOM_NUMBER,
    UNFK.ID,
    UNFK.QUANTITY
    FROM
    ZZZ_ROOM_MASTER_EX,
    TABLE(ZZZ_SANDBOX_EX.UNFK(ZZZ_ROOM_MASTER_EX.FEATURES)) UNFK
    Now, the big question is--how do I do this from OWB? I've tried several different variations of my function and settings in OWB to see if I can build a single SELECT statement which joins a regular table with a table function--but none of them seem to work, I end up getting SQL generated that won't compile because it doesn't see the source table right:
    INSERT
    /*+ APPEND PARALLEL("ZZZ_ROOM_FEATURES_EX") */
    INTO
    "ZZZ_ROOM_FEATURES_EX"
    ("ROOM_NUMBER",
    "FEATUREID",
    "QUANTITY")
    (SELECT
    "ZZZ_ROOM_MASTER_EX"."ROOM_NUMBER" "ROOM_NUMBER",
    "INGRP2"."ID" "ID_1",
    "INGRP2"."QUANTITY" "QUANTITY"
    FROM
    (SELECT
    "UNFK"."ID" "ID",
    "UNFK"."QUANTITY" "QUANTITY"
    FROM
    TABLE ( "ZZZ_SANDBOX_EX"."UNFK2" ("ZZZ_ROOM_MASTER_EX"."FEATURES")) "UNFK") "INGRP2",
    "ZZZ_ROOM_MASTER_EX" "ZZZ_ROOM_MASTER_EX"
    As you can see, it's trying to create a sub-query in the FROM clause--causing it to just ask for "ZZZ_ROOM_MASTER_EX"."FEATURES" as an input--which isn't available because it's outside of the sub-query!
    Is this some kind of bug with the code generator or am I doing something seriously wrong here? Any help will be greatly appreciated!

    Hello Everybody!
    Thank you for all your response!
    I had changes this work area into Internal table and changed the select query. PLease let me know if this causes any performance issues?
    I had created a Z table with the following fields :
    ZADS :
    MANDT
    VKORG
    ABGRU.
    I had written a select query as below :
    I had removed the select single and insted of using the Structure it_rej, I had changed it into Internal table 
    select vkorg abgru from ZADS into it_rej.
    Earlier :
    IT_REJ is a Work area:
    DATA : BEGIN OF IT_REJ,
    VKORG TYPE VBAK-VKORG,
    ABGRU TYPE VBAP-ABGRU,
    END OF IT_REJ.
    Now :
    DATA : BEGIN OF IT_REJ occurs 0,
    VKORG TYPE VBAK-VKORG,
    ABGRU TYPE VBAP-ABGRU,
    END OF IT_REJ.
    I guess this will fix the issue correct?
    PLease suggest!
    Regards,
    Developer.

  • Need some help with a counting function

    Hello,
    I use a simple sheet to organize the timetable of my patients. Now I'd like to count how many different patients I attend, without counting a patient twice if I attend him twice a week for example. My sheet looks like this:
    Mon
    Tue
    Wed
    Thu
    John
    Steve
    John
    Wesley
    Mary
    Harry
    Deborah
    Peter
    Arnold
    Carol
    Chris
    Mary
    Sarah
    Karen
    Karen
    Carol
    Larry
    Peter
    So the answer would be 13, because I attend 13 different patients a week. Fields in blank should no be counted, the cell contend changes frequently.
    A friend of mine tried to help me with a countif function but it didn't work out for me, it would count the fields left blank too.
    Any idea?
    Thanks, gabriel

    Hi Gabriel,
    Here's another, more generalized, approach that doesn't need adjusting for maximum number of visits/week at the cost of just a few more formulas.  But only two tables!
    Formula in A2 and copied down:
      =ROUNDUP((ROW(cell)−1)÷$B$27,0)
    Formula in B2 and copied down:
      =IF(MOD(ROW(cell)−1,$B$27)=0,$B$27,MOD(ROW(cell)−1,$B$27))
    The formula in C2 and copied down:
      =OFFSET(Schedule::$A$1,0,B−1)
    The formula in D2 and copied down:
      =IFERROR(OFFSET(Schedule::$A$1,A2,B2−1,rows,columns),"")
    The formula in E2 and copied down:
      =IF(AND(D2≠0,LEN(D2)>0),COUNTIF($D$1:D2,D2),"")
    The formula in F2 and copied down:
      =IFERROR(IF(E=1,1,""),"")
    The formula in F27:  =SUM(F)
    The value in B27 is 4, the number of day columns in the Schedule table. You would change that if you increase or decrease the number of days on which you see patients.
    Column C is cosmetic, not needed in the calculation.
    The error triangle means all of the cells in the Schedule table are already accounted for in the rows above.
    Probably more compact ways to do this but it gets the job done.
    SG

  • Need some help with a remove function

    Design and code a program that will maintain a list of product names. Use a String type to represent the product name and an array of strings to implement the list. Your program must implement the following methods:
    Add a product to the list
    Remove a product from the list
    Display then entire list
    Find out if a particular product is on the list.
    You need to create a command command loop with a menu() function. The program must continue asking for input until the user stops.
    This is the assignment and this is what I have so far. I need some help writing the remove function.
    Thanks
    * Title: SimpleSearchableList.java
    * Description: this example will show a reasonably efficient and
    * simple algorithm for rearranging the value in an array
    * in ascending order.
    public class SimpleSearchableList {
         private static String[] List = new String[25]; //These variables (field variables)
         private static int Size; //are common to the entire class, but unavailable
         //except to the methods of the class...
         public static void main(String[] args)
              String Cmd;
              for(;;) {
                   Menu();
                   System.out.print("Command: ");
                   Cmd = SimpleIO.inputString();
                   if(Cmd.equals("Quit"))
                        break;
                   else if(Cmd.equals("Fill"))
                        FillList();
                   else if(Cmd.equals("Search"))
                        SearchList();
                   else if(Cmd.equals("Show"))
                        ShowList();
                   else if(Cmd.equals("Remove"))
                        Remove();
         //Tells you what you can do...
         public static void Menu()
              System.out.println("Choices..................................");
              System.out.println("\tFill to Enter Product");
              System.out.println("\tShow to Show Products");
              System.out.println("\tSearch to Search for Product");
              System.out.println("\tRemove a Product");
              System.out.println("\tQuit");
              System.out.println(".........................................");
         //This method will allow the user to fill an array with values...
         public static void FillList()
              int Count;
              System.out.println("Type Stop to Stop");
              for(Count = 0 ; Count < List.length ; Count++)
                   System.out.print("Enter Product: ");
                   List[Count] = SimpleIO.inputString();
                   if(List[Count].equals("Stop"))
                        break;
              Size = Count;
         //This method will rearrange the values in the array so that
         // go from smallest to largest (ascending) order...
         public static void SearchList()
              String KeyValue;
              boolean NotFoundFlag;
              int Z;
              System.out.println("Enter Product Names Below, Stop To Quit");
              while(true)
                   System.out.print("Enter: ");
                   KeyValue = SimpleIO.inputString();
                   if(KeyValue.equals("Stop")) //Note the use of a method for testing
                        break; // for equality...
                   NotFoundFlag = true; //We'll assume the negative
                   for(Z = 0 ; Z < Size ; Z++)
                        if(List[Z].equals(KeyValue)) {
                             NotFoundFlag = false; //If we fine the name, we'll reset the flag
              System.out.println(List[Z] + " was found");
                   if(NotFoundFlag)
                        System.out.println(KeyValue + " was not found");     
         //This method will display the contents of the array...
         public static void ShowList()
              int Z;
              for(Z = 0 ; Z < Size ; Z++)
                   System.out.println("Product " + (Z+1) + " = " + List[Z]);
         public static void Remove()
    }

    I need help removing a product from the arrayYes. So what's your problem?
    "Doctor, I need help."
    "What's wrong?"
    "I need help!"
    Great.
    By the way, you can't remove anything from an array. You'll have to copy the remaining stuff into a new one, or maybe maintain a list of "empty" slots. Or null the slots and handle that. The first way will be the easiest though.

  • Need help with user defined function

    Hello SDN,
    I need some help with a user-defined function. My source message contains multiple
    generic records (1000 char string), and my target message is 1 header record,
    then multiple generic records.  See description of source and target messages below:
    Source:
      GenericRecordTable 1..unbounded
        Row (1000 char string)
    Target:
      Field1 (char5)
      Field2 (char5)
      Field3 (char5)
      IT_Data
        GenericRecordTable 1..unbounded
          Row (1000 char string)
    Basically, what I need to do in my user defined funtion is to map the first record
    in my source record to the 3 header fields, then map all of the rest of the records
    (starting from line 2) into the GenericRecordTable.
    Can someone please help me with the code for the user defined function(s) for this
    mapping?
    Thank you.

    hi,
    Activities
    1. To create a new user-defined function, in the data-flow editor, choose Create New Function (This
    graphic is explained in the accompanying text), which is located on the lower left-hand side of the
    screen. In the menu, choose Simple Function or Advanced Function.
    2. In the window that appears, specify the attributes of the new function:
    Name
    Technical name of the function. The name is displayed in the function chooser and on the data-flow
    object.
    Description
    Description of how the function is used.
    Cache
    Function type (see above)
    Argument Count
    In this table, you specify the number of input values the function can process, and name them. All
    functions are of type String.
    3. In the window that appears, you can create Java source code:
    a. You can import Java packages to your methods from the Imports input field, by specifying them
    separated by a comma or semi-colon:
    You do not need to import the packages java.lang., java.util., java.io., and java.lang.reflect. since
    all message mappings require these packages and therefore import them. You should be able to
    access standard JDK and J2EE packages of the SAP Web Application Server by simply specifying the
    package under Import. In other words, you do not have to import it as an archive into the Integration
    Repository. You can also access classes of the SAP XML Toolkit, the SAP Java Connector, and the
    SAP Logging Service (see also: Runtime Environment (Java-Mappings)).
    In addition to the standard packages, you can also specify Java packages that you have imported as
    archives and that are located in the same, or in an underlying software component version as the
    message mapping.
    b. Create your Java source text in the editor window or copy source text from another editor.
    4. Confirm with Save and Close.
    5. User-defined functions are limited to the message mapping in which you created the function. To
    save the new function, save the message mapping.
    6. To test the function, use the test environment.
    The new function is now visible in the User-Defined function category. When you select this category,
    a corresponding button is displayed in the function chooser pushbutton bar. To edit, delete, or add the
    function to the data-flow editor, choose the arrow next to the button and select from the list box
    displayed.
    http://help.sap.com/saphelp_nw04/helpdata/en/d9/718e40496f6f1de10000000a1550b0/content.htm
    http://java.sun.com/j2se/1.5.0/docs/api/
    /people/krishna.moorthyp/blog/2006/07/29/documentation-html-editor-in-xi
    /people/sap.user72/blog/2006/02/06/xi-mapping-tool-exports
    http://help.sap.com/saphelp_nw04/helpdata/en/43/c4cdfc334824478090739c04c4a249/content.htm
    UDF -
    http://help.sap.com/saphelp_nw04/helpdata/en/22/e127f28b572243b4324879c6bf05a0/content.htm
    Regards

  • Help with SMTP class function with authentication

    My server is no longer supporting the php mail() functionality.  I need to use SMTP class function with authentication in my php code and they suggested this to replace it: http://www.yrhostsupport.com/index.php?/Knowledgebase/Article/View/101/2/smtp-class-functi on-with-authentication-in-php-code
    So I tried it, but can't get it to work. This is my test form:
    <form method="post" action="forms/sendmail-test2.php" onsubmit="return checkEmail(this);">
    <script type="text/javascript" language="JavaScript">
    </script>
    <fieldset><legend>Info</legend>
    <label> Name </label>
      <input type="text"
      name="name" size="30" maxlength="40"/><br />
    <label> <span class="redText">*</span> Email </label>
        <input name="email" type="text" size="30" maxlength="40"/>
        <br />
    <label><span class="redText">*</span> Message </label>
      <textarea cols="40" rows="5" name="message" type="text" /></textarea><br />
        </fieldset>
    <input type="reset" value="Reset" />
    <input type=submit value="Submit Form" />
    </fieldset>
    </form>
    This is sendmail-test2.php where the form goes. It won't send unless I comment out the first 10 lines.
    <?php
    include('Mail.php');
    //$to = "[email protected]";
    //$name = $_REQUEST['name'] ;
    //$email = $_REQUEST['email'] ;
    //$message = $_REQUEST['name'] ;
    //$headers = "From: $email";
    //$subject = " price quote";
    //$fields = array();
    //$fields{"name"} = "Name"; 
    //$fields{"email"} = "Email";
    //$fields{"message"} = "Message";
    $recipients = '[email protected]'; //CHANGE
    $headers['From']    = '[email protected]'; //CHANGE
    $headers['To']      = '[email protected]'; //CHANGE
    $headers['Subject'] = 'Test message';
    $body = 'Test message';
    // Define SMTP Parameters
    $params['host'] = 'levy.dnsbox25.com';
    $params['port'] = '25';
    $params['auth'] = 'PLAIN';
    $params['username'] = '[email protected]'; //CHANGE
    $params['password'] = 'xxxxxx'; //CHANGE
    /* The following option enables SMTP debugging and will print the SMTP
    conversation to the page, it will only help with authentication issues. */
    $params['debug'] = 'true';
    // Create the mail object using the Mail::factory method
    $mail_object =& Mail::factory('smtp', $params);
    // Print the parameters you are using to the page
    foreach ($params as $p){
          echo "$p<br />";
    // Send the message
    $mail_object->send($recipients, $headers, $body);
    ?>
    It used to work fine when I used
    $send = mail($to, $subject, $body, $headers);
    $send2 = mail($from, $subject2, $autoreply, $headers2);
    But they said I can't use it any more. I'm good with HTML and CSS but I don't know much about php. Thanks for any help integrating a from into this new code!

    Thanks, bregent. I changed it to this and it sends, but nothing shows up in the body except "Test message". How would I "insert the form fields' 'email' and 'name' and 'message' in the body"?
    <?php
    include('Mail.php');
    $to = "[email protected]";
    $name = $_REQUEST['name'] ;
    $email = $_REQUEST['email'] ;
    $message = $_REQUEST['name'] ;
    //$headers = "From: $email";
    $subject = " price quote";
    $fields = array();
    $fields{"name"} = "Name"; 
    $fields{"email"} = "Email";
    $fields{"message"} = "Message";
    $recipients = '[email protected]'; //CHANGE
    $headers['From']    = '[email protected]'; //CHANGE
    $headers['To']      = '[email protected]'; //CHANGE
    $headers['Subject'] = 'Test message';
    $body = 'Test message';
    $fields = array();
    $fields{"name"} = "Name"; 
    $fields{"email"} = "Email";
    $fields{"message"} = "Message";
    // Define SMTP Parameters
    $params['host'] = 'levy.dnsbox25.com';
    $params['port'] = '25';
    $params['auth'] = 'PLAIN';
    $params['username'] = '[email protected]'; //CHANGE
    $params['password'] = xxx'; //CHANGE
    /* The following option enables SMTP debugging and will print the SMTP
    conversation to the page, it will only help with authentication issues. */
    $params['debug'] = 'true';
    // Create the mail object using the Mail::factory method
    $mail_object =& Mail::factory('smtp', $params);
    // Print the parameters you are using to the page
    foreach ($params as $p){
          echo "$p<br />";
    // Send the message
    $mail_object->send($recipients, $headers, $body);
    ?>

  • Help with a PLSQL Function

    I am having problems with a SQL Function:
    CREATE OR REPLACE FUNCTION GDRREPORTS.MONTHTOTALS
    (BDate IN DATE)
    RETURN INTEGER
    AS
    ShakeCount INTEGER
    BEGIN
    ShakeCount=(Select count (distinct b.patid),
    to_char(gdrreports.To_Date_w_error (t.data), 'MON') BDay_month,
    to_char(gdrreports.To_Date_w_error (t.data), 'YYYY') BDay_year
    FROM CCI.a_patientlist p
    Inner Join CCI.PATIENTEDUCATIONNOTE_SCN_216IL b on
    b.patid=p.patid and b.tag=1789
    Inner join CCI.BIRTHDATE_519 t on
    t.patid=p.patid
    where p.unit != 'TRAIN' and p.admtime>='01JAN2011'
    and b.Data ='X'
    and to_char(gdrreports.To_Date_w_error (t.data), 'YYYY')=to_char(Bdate, 'YYYY')
    and to_char(gdrreports.To_Date_w_error (t.data), 'MON')=to_char(Bdate, 'MON'))
    RETURN ShakeCount ;
    EXCEPTION
    WHEN OTHERS THEN
    RETURN NULL;
    END MONTHTOTALS;
    Not exactly sure what's wrong with it.
    Thank you.

    871359 wrote:
    I am having problems with a SQL Function:
    CREATE OR REPLACE FUNCTION GDRREPORTS.MONTHTOTALS
    (BDate IN DATE)
    RETURN INTEGER
    AS
    ShakeCount INTEGER
    BEGIN
    ShakeCount=(Select count (distinct b.patid),
    to_char(gdrreports.To_Date_w_error (t.data), 'MON') BDay_month,
    to_char(gdrreports.To_Date_w_error (t.data), 'YYYY') BDay_year
    FROM CCI.a_patientlist p
    Inner Join CCI.PATIENTEDUCATIONNOTE_SCN_216IL b on
    b.patid=p.patid and b.tag=1789
    Inner join CCI.BIRTHDATE_519 t on
    t.patid=p.patid
    where p.unit != 'TRAIN' and p.admtime>='01JAN2011'
    and b.Data ='X'
    and to_char(gdrreports.To_Date_w_error (t.data), 'YYYY')=to_char(Bdate, 'YYYY')
    and to_char(gdrreports.To_Date_w_error (t.data), 'MON')=to_char(Bdate, 'MON'))
    RETURN ShakeCount ;
    EXCEPTION
    WHEN OTHERS THEN
    RETURN NULL;
    END MONTHTOTALS;
    Not exactly sure what's wrong with it.Without additional clues, we can't guess.
    It would help if you used COPY & PASTE so we can see this reported problem too.

  • Help with SQL Round

    I need to round up my Percentage column in my query below and couldnt quite get the ROUND function right. Right now I am getting:
    28.888888800
    would like
    28.89%
    SELECT
    a.doctor as Doctor
    , a.financialclass AS FinancialClass
    , COUNT( a.PatientVisitId ) / CAST( sub.the_count AS DECIMAL( 8 , 2 )) *100 AS Percentage
    FROM
    #temp a JOIN(
    SELECT
    doctor
    , COUNT( patientvisitid )AS the_count
    FROM #temp
    GROUP BY
    doctor )sub ON a.doctor = sub.doctor
    GROUP BY
    a.doctor
    , a.FinancialClass
    , sub.the_count
    ORDER BY
    Doctor , FinancialClass;

    Hi Vishkey,
    If you mean that you prefer to do it in the application that get the data from the SQL and not at the SQL query level, then I think it is not black and white. There are pros and cons, for example:
    * If we have a lot of data that need to transfer from the SQL to the App I will tr to minimize it and sending the value 22.22 is much less then sending 22.22222222 for example.
    * If we need to do some math calculation then I will prefer to pass the whole number to get more acurate. Since we can alway convert 22.22222222 into 22.22 but not vise versa.
    * In genaral I agree that if this is a display problem that in most cases I will do it in the app level and not the SQL Query.
    Since we are in the T-SQL forum I will go with Naomi solution this time :-)
    In Asp.Net forum I would probably go with your solution :-)
    [Personal Site] [Blog] [Facebook]

  • Help with this cool function: =SUMIF(Table 1::$Month, COLUMN()−1, $Cost)

    Hello,
    I am a novice with respect to spreadsheet functions and needed a a cashflow spreadsheet.  I found this one (Download Cashflow Tracker for Numbers (iWork 09).) which is perfect but the author, I suspect, has not updated his website in years.  I attempted contacting him and received no reply.
    I receive an error with the following function:
    =SUMIF(Table 1::$Month, COLUMN()−1, $Cost)
    This occurs when I enter a date in the expense or income table.  Entering the date is required to make the spreadsheet work but when I do I receive an error that a number is expected when a date is entered.
    Can anyone give me some advice?  I would really like to use this spreadsheet.
    Thanks!
    Steve

    What I have found the simplest approach has been:
    1. Cut the Summary by Category table and paste it into the Transaction sheet, giving something like this (after rearranging renaming, etc, as desired):
    2. Make sure the links between the two table are still working, make their appearance the way you like, then duplicate that sheet for the other months.  Each sheet will then have its separate set of two interconnected tables.
    3. Copy paste one of the Summary tables back to the Summary sheet, rename it as desired, and set it up with formulas referencing the tables in the monthly sheets you have set up, something like this:
    If you want your summary by month you would set up 12 columns in the main 'Summary by Category' table, with each column referencing a different sheet.  Your Budget could be a row above each Actual figure, if you like, with difference in a row below that.
    This approach keeps the formulas simple and avoids having to set up fancy SUMIFS extracting data for each month from one big Transaction table.
    SG

  • Need Help With Save As function Very Important

    i working on a project and i have to create a Save As function for it. When you click on Save As its supposed to open a dialog window where u can choose the where you would like to save the file and what you would like to name it. I know there is alot wrong with my code but i'm not sure on how to fix it so any and all help is greatly appreciated
    private void doSaveAs(){
              //display file dialog
              FileDialog fDialog2 = new FileDialog (this, "Save As...", FileDialog.SAVE);
              fDialog2.setVisible(true);
              //Set the file name chosen by user
              String name = fDialog2.getFile();
              // user canceled file selection, return without doing anything.
              if(name == null)
                   return;
              fileName = fDialog2.getDirectory() + name;
              // Try to create a file writer
              FileWriter writer = null;
              try{
                   writer = new FileWriter(fileName);
              } catch (IOException ioe){
                   MessageDialog dialog = new MessageDialog (this, "Error Message",
                             "Error writing the file: "+ioe.toString());
                   dialog.setVisible(true);
                   return;
              BufferedWriter bWriter = new BufferedWriter(writer);
              //Try to write the file
              StringBuffer textBuffer = new StringBuffer();
              try {
                   String textLine = bWriter.write(2);
                   while (textLine != null) {
                        textBuffer.append(textLine + '\n');
                        textLine = bWriter.write(name);
                   bWriter.close();
                   writer.close();
              } catch (IOException ioe){
                   MessageDialog dialog = new MessageDialog (this, "Error Message", "Error writing file: "+ioe.toString());
                   dialog.setVisible(true);
                   return;
         setTitle("JavaEdit " +name);     // reset frame title
         text.setText(textBuffer.toString());
    null

    And again with indentation
       private void doSaveAs(){
       //display file dialog
       FileDialog fDialog2 = new FileDialog (this, "Save As...",     
       FileDialog.SAVE);
          fDialog2.setVisible(true);
       //Set the file name chosen by user
       String name = fDialog2.getFile();
       // user canceled file selection, return without doing anything.
       if(name == null)
          return;
       fileName = fDialog2.getDirectory() + name;
       // Try to create a file writer
       FileWriter writer = null;
          try{
             writer = new FileWriter(fileName);
          } catch (IOException ioe){
          MessageDialog dialog = new MessageDialog (this, "Error Message", "Error writing the file: "+ioe.toString());
                dialog.setVisible(true);
                return;
       BufferedWriter bWriter = new BufferedWriter(writer);
       //Try to write the file
       StringBuffer textBuffer = new StringBuffer();
       try {
          String textLine = bWriter.write(2);
          while (textLine != null) {
             textBuffer.append(textLine + '\n');
             textLine = bWriter.write(name);
          bWriter.close();
          writer.close();
       } catch (IOException ioe){
          MessageDialog dialog = new MessageDialog (this, "Error Message", "Error writing file: "+ioe.toString());
          dialog.setVisible(true);
          return;
       setTitle("JavaEdit " +name); // reset frame title
       text.setText(textBuffer.toString());
    }

  • Need help with an array function

    I'm using the array index function and i would like to be able to control what elements go out on it.  For example, if i wanted only the first element to go out, i don't want the second element to send out zero.  Is there any way i can control what elements leave the array index function.  I also don't understand what the index inputs do on that function either.  If anyone has any advice on the application or can modify it in any way, please help.
    Attachments:
    Array and for loop.vi ‏1190 KB

    The index inputs determine what elements are retrieved. For example of you would wire a 10 and a 20 to your two index inputs, you would bet element #10 and element #20 of your array. You can resize it to get any desired number of elements.
    If you don't wire the index inputs, you'll get the first two elements.
    If you only wire the top index input (e.g a 10), you'll get element #10 and #11.
    LabVIEW Champion . Do more with less code and in less time .

  • Help with Oracle Analytic Function scenario

    Hi,
    I am new to analytic functions and was wondering if someone could help me with the data scenario below. I have a table with the following data
    COLUMN A COLUMN B COLUMN C
    13368834 34323021 100
    13368835 34438258 50
    13368834 34438258 50
    13368835 34323021 100
    The output I want is
    COLUMN A COLUMN B COLUMN C
    13368834 34323021 100
    13368835 34438258 50
    A simple DISTINCT won't give me the desired output so i was wondering if there is any way that I can get the result using ANALYTIC FUNCTIONS and DISTINCT ..
    Any help will be greatly appreciated.
    Thanks.

    Hi,
    Welcome to the forum!
    Whenever you have a question, please post your sample data in a form that people can use to re-create the problem and test their solutions.
    For example:
    CREATE TABLE     table_x
    (      columna     NUMBER
    ,      columnb     NUMBER
    ,      columnc     NUMBER
    INSERT INTO table_x (columna, columnb, columnc) VALUES (13368834, 34323021, 100);
    INSERT INTO table_x (columna, columnb, columnc) VALUES (13368835, 34438258, 50);
    INSERT INTO table_x (columna, columnb, columnc) VALUES (13368834, 34438258, 50);
    INSERT INTO table_x (columna, columnb, columnc) VALUES (13368835, 34323021, 100);Do you want something that works in your version or Oracle? Of course you do! So tell us which version that is.
    How do you get the results that you want? Explain what each row of output represents. It looks like
    the 1st row contains the 1st distinct value from each column (where "first" means descending order for columnc, and ascending order for the others),
    the 2nd row contains the 2nd distinct value,
    the 3rd row contains the 3rd distinct value, and so on.
    If that's what you want, here's one way to get it (in Oracle 9 and up):
    WITH     got_nums     AS
         SELECT     columna, columnb, columnc
         ,     DENSE_RANK () OVER (ORDER BY  columna        )     AS a_num
         ,     DENSE_RANK () OVER (ORDER BY  columnb        )     AS b_num
         ,     DENSE_RANK () OVER (ORDER BY  columnc  DESC)     AS c_num
         FROM     table_x
    SELECT       MAX (a.columna)          AS columna
    ,       MAX (b.columnb)          AS columnb
    ,       MAX (c.columnc)          AS columnc
    FROM              got_nums     a
    FULL OUTER JOIN  got_nums     b     ON     b.b_num     =           a.a_num
    FULL OUTER JOIN  got_nums     c     ON     c.c_num     = COALESCE (a.a_num, b.b_num)
    GROUP BY  COALESCE (a.a_num, b.b_num, c.c_num)
    ORDER BY  COALESCE (a.a_num, b.b_num, c.c_num)
    ;I've been trying to find a good name for this type of query. The best I've heard so far is "Prix Fixe Query", named after the menus where you get a choice of soups (listed in one column), appetizers (in another column), main dishes (in a 3rd column), and so on. The items on the first row don't necessaily have any relationship to each other.
    The solution does not assume that there are the same number of distinct items in each column.
    For example, if you add this row to the sample data:
    INSERT INTO table_x (columna, columnb, columnc) VALUES (13368835, 34323021, 99);which is a copy of the last row, except that there is a completely new value for columnc, then the output is:
    `  COLUMNA    COLUMNB    COLUMNC
      13368834   34323021        100
      13368835   34438258         99
                                  50starting in Oracle 11, you can also do this with an unpivot-pivot query.

  • Help with remove.Instance function removing the wrong row

    Hi there,
    I have been working on Livecycle forms for about two weeks now and have been able to work out quite a bit of what I need to do.  However, I am really hoping someone can help me with a two problems that I cannot seem to solve. 
    The first one is; if I click on the 'remove a row' function on my form and it is the only row, it comes up with an error message,  How do I stop that from being displayed?  I think I need to use the IF function with >1 but cannot seem to get it to work.
    Secondly, if for example I add two rows using the +row button to make three rows and in rows 1&2 I input some data.  If I then want to delete row 3 and press the -Row button it deletes row number 2 and the data in that row and leaves row number 3.  How can I change it so that when I delete a row it deletes row number three and leaves row number 2.  essentially, I need it to delete rows from the bottom up and not from the top down.  Hope this makes sense.  Any help would be greatly appreciated!
    Attached is a link to my form.
    https://copy.com/RiktBtj0uiSA
    Thank you.

    Hi there,
    When removing instances within an object's event which is inside the instance, you must make sure that you remove this particular instance at the end of the event.
    E.g.:
    If you remove the instance of which the button is inside before even finishing the whole event, the program will not recognize what event is to be finished because you have removed the object's which is fired..
    So here you are trying to finish some code which doesn't exist anymore ...
    I suggest you should always remove the instance of (this) object at the end of any event to make sure to finish all your actions before deleting the object.
    Hope this help!

  • Need help with a round off.

    Hiya.
    I'm trying to get a little program to work (schoolwork I admit) but the end result is a little different then what I need it to be (and not asking for spoons here please).
    I'm trying to get the end result like xx.x but for the moment it ends up with several more digits (like xx.xxxxxxxxxxxx).
    Since I want it to round off like it should (second digit) <5 down to number below and >5 to number above, is there any way to stop a double on two digits?
    I'm using notepad and JDK and not allowed to use predefined methods (for a good reason I assume :P)
    public class Swim{
       public static void main(String[] args){
       System.out.println("Please write the difficulty for your jump: ");
       double diff = Keyboard.readDouble();
       System.out.println("");
       System.out.println("Please write the judges points for the jump.");
       System.out.println("Judge #1: ");
       double tal1 = Keyboard.readDouble();
       System.out.println("Judge #2: ");
       double tal2 = Keyboard.readDouble();
       System.out.println("Judge #3: ");
       double tal3 = Keyboard.readDouble();
       System.out.println("Judge #4: ");
       double tal4 = Keyboard.readDouble();
       System.out.println("Judge #5: ");
       double tal5 = Keyboard.readDouble();
    //Find highest number.
       double max = 0;
       if (tal1 >= max){
          max=tal1;
       if (tal2 >= max){
          max=tal2;
       if (tal3 >= max){
          max=tal3;
       if (tal4 >= max){
          max=tal4;
       if (tal5 >= max){
          max=tal5;
    //Find lowest number.
       double min = 0;
       if (tal1 >= min){
          min=tal1;
       if (tal2 <= min){
          min=tal2;
       if (tal3 <= min){
          min=tal3;
       if (tal4 <= min){
          min=tal4;
       if (tal5 <= min){
          min=tal5;
    //Calculate points. difficulty*(the judgepoints - highest and lowest score)
       double summa = diff*(tal1+tal2+tal3+tal4+tal5-max-min);
       System.out.println("");
       System.out.println("Your jump scored: " + summa);
    }

    i hope this helps....
    i just discovered it a few hours ago.
    if your input is double like
    double <name>=<value>;
    you can assign another variable which will convert it to int
    int d=(int)i;
    i hope it helps...=)

Maybe you are looking for