Union two tables with diffrent count of fields with null and float value

Hello,
i want to union two tables, first one with 3 fields and second one with 4 fields (diffrent count of fields).
I can add null value at end of first select but it does not work with float values in second table. Value form second table is convert to integer.
For example:
select null v1 from sessions
union
select 0.05 v1 from sessions
result is set of null and 0 value.
As workaround i can type:
select null+0.0 v1 from sessions
union
select 0.05 v1 from sessions
or simple change select's order.
Is any better/proper way to do this? Can I somehow set float field type in first select?
Best regards,
Lukasz.
WIN XP, MAXDB 7.6.03

Hi Lukasz,
in a UNION statement the first statement defines the structure (number, names and types of fields) of the resultset.
Therefore you have to define a FLOAT field in the first SELECT statement in order to avoid conversion to VARCHAR.
Be aware that NULL and 0.0 are not the same thus NULL+0.0 does not equal NULL.
In fact NULL cannot equal to any number or character value at all.
BTW: you may want to use UNION ALL to avoid the search and removal of duplicates - looks like your datasets won't contain duplicates anyhow...
Regards,
Lars

Similar Messages

  • How to count ONLY fields with a specific value

    I modified the code below from the API reference to count combobox fields with a value of "MT" so I could total the number of a specific choice the form user input.
    var count = 0;
    for (var i=0; i<this.numFields; i++)
    var fname = this.getNthFieldName(i);
    if ( this.getField(fname).type == "combobox" && this.getField(fname).value == "MT" ) count++;
    this.getField("mTurb").value = count.value;
    Here's the problem: I tried to use a similar script, modified only slightly from this form, in another total field to tally a different choice made with comboboxes and the script continues to tally the first choice. An example of one of the modified versions of the script is below.
    var gcount = 0;
    for (var i=0; i<this.numFields; i++)
    var gname = this.getNthFieldName(i);
    if ( this.getField(gname).type == "combobox" && this.getField(gname).value == "MT" ) gcount++;
    this.getField("gPack").value = gcount.value;
    I suspect I'm just missing something painfully obvious to seasoned scripters, but I can't seem to figure it out and I need this script to be able to count the number of 9 different options in the comboboxes.

    OK, you can use a script like the following as the custom calculate script for the text fields that perform the counts:
    // Custom calculate script for text field
    (function () {
        // Declare and initialize variables
        var fn, s = "MT", count = 0;
        // Loop through the combo boxes
        for (var i = 1; i < 25; i++) {
            // Determine the current field name
            fn = "M" + util.printf("%02d", i));
            // See if the field value matches
            if (getField(fn).valueAsString === s) count++
        // Set this field value to the count
        event.value = count;
    Change the value of the "s" variable to match the item that you want to count. The first and last lines prevent the unnecessary creatio of global variables, which is good. It also makes it easy to transfer to a more general document-level routine, which would be event better, something like:
    // Custom calculate script for text field
    function getCBCount(s) {
        var fn, count = 0;
        // Loop through the combo boxes
        for (var i = 1; i < 25; i++) {
            // Determine the current field name
            fn = "M" + util.printf("%02d", i));
            // See if the field value matches
            if (getField(fn).valueAsString === s) count++
        // Set this field value to the count
        event.value = count;
    You would then call this function from the individual text boxes with the following custom calculate script:
    getCBCount("MT");
    and replace "MT" with the vlaue you want to count.

  • From two given tables, how do you fetch the values from two columns using values from one column(get values from col.A if col.A is not null and get values from col.B if col.A is null)?

    From two given tables, how do you fetch the values from two columns using values from one column(get values from col.A if col.A is not null and get values from col.B if col.A is null)?

    Hi,
    Use NVL or COALESCE:
    NVL (col_a, col_b)
    Returns col_a if col_a is not NULL; otherwise, it returns col_b.
    Col_a and col_b must have similar (if not identical) datatypes; for example, if col_a is a DATE, then col_b can be another DATE or it can be a TIMESTAMP, but it can't be a VARCHAR2.
    For more about NVL and COALESCE, see the SQL Language manual: http://docs.oracle.com/cd/E11882_01/server.112/e26088/functions119.htm#sthref1310
    I hope this answers your question.
    If not, post a little sample data (CREATE TABLE and INSERT statements, relevant columns only) for all tables involved, and also post the results you want from that data.
    Explain, using specific examples, how you get those results from that data.
    Always say which version of Oracle you're using (e.g., 11.2.0.2.0).
    See the forum FAQ: https://forums.oracle.com/message/9362002

  • Having issues with populating a Text Field with data from 2 other fields

    I have 3 fields Tools_1a_pri, Tools_1a_pri_other, Tools_1a_pri_txt.
    Tools_1a_pri is a drop down combo with a predefined list. One of the options is "Other".  When "Other" is selected, the text field Tools_1a_pri_other becomes visible for users to enter the name of the other tool.
    The Tools_1a_pri_txt is a text field with a calculation that shows either text stating that no tool has been selected or the Tools_1a_pri & or Tools_1a_pri_other.
    When I select one of the predefined tools, everything works.  When I select other, it appears that nothing has changed.  It requires that I click on another field before it populates.  This is confusing to the user.
    Tools_1a_pri   Validate code
    this.getField("Tools_1a_pri_Other").display = event.value=="Other" ? display.visible : display.hidden;
    Tools_1a_pri_txt  Calculation code
    //if nothing is selected, do the following
    if (getField("Tools_1a_pri").value.length < 2) {
    event.target.textColor = color.red
    event.value = "No primary tool identified";
    }else if (getField("Tools_1a_pri").value != "Other") {
    //otherwise do this if other is selected
    event.target.textColor = color.black
    event.value = getField("Tools_1a_pri").value;
    }else if (getField("Tools_1a_pri").value = "Other") {
    //otherwise do this if other is not selected
    event.target.textColor = color.black
    event.value = getField("Tools_1a_pri").value + " - " + getField("Tools_1a_pri_Other").value;

    You made the classic mistake of using the assignment operator in an if-statement instead of the comparison operator. Change this line:
    } else if (getField("Tools_1a_pri").value = "Other") {
    To this:
    } else if (getField("Tools_1a_pri").value == "Other") {

  • Textare with character counter versus textarea with html editor

    Hi
    I am using a textarea with html editor. I need to restrict the user to not type more than 25000 characters? Can someone tell me as to how I can do that?
    I know that one can set the maximum width for textarea with character counter and it prevents one from typing in more than the maximun specified, but I really need to use the html editor. Thanks.
    suni

    This is caused by the charCount javascript function, which dynamically sets the text colour to 'red' when the maximum number of characters is entered, but "resets" it to 'black'.
    Guess the way to avoid this is to create your own equivalent of the charCount function that captures the actual colour from the DOM and attach it to a textarea using the onchange and onkeyup attributes used in the built-in one.

  • How to multiply a numeric field (with Quantity) with a Cell (text field with price) to get a total?

     

    In Javascript I suggest multiplying the text field by 1 to change it to a numeric type then multiply this with the other numeric field.  The code would look something like:
    Total.rawValue = numericField.rawValue * (textField.rawValue*1)

  • How to deal with Select Menu when it can NULL or a Value with SQL

    I have a SELECT Menu(:P_55X) with:
    "NULL DISPLAY VALUE" = NULL
    "NULL RETURN VALUE" = NULL
    The Chart query is as follows.
    SELECT NULL LINK,
    START_DATE "FOR_MONTH",
    ROUND(AVG("SLA"),3) "SLA_UPTIME"
    from SLA_TIMES_ZABBIX
    LEFT JOIN (SELECT DISTINCT NODE_NAME,OS_TYPE from CMS.CMS_NODE_OS where remove_dt is NULL) OSNODE on LOWER(SLA_TIMES_ZABBIX.NODE_NAME)=LOWER(OSNODE.NODE_NAME)
    where OS_TYPE=:P55_X group by START_DATE order by START_DATE ASC;
    How can I accout for the (:P55_X) variable being NULL sometimes and not null other times. meaning I can't use the "=" when the values is null because I need a IS NULL there.
    The column in the database either has a value or is NULL.
    Thanks
    Robert

    where (OS_TYPE = :P55_X OR (:P55_X IS NULL and OS_TYPE IS NULL))

  • How can I maintain two tables content at the same time with SM30

    Hi all,
    I created two customizing tables that I would like to link together for maintenance in SM30. Table 1 is the header and table 2 can have multiple detail records.
    They are linked via the ID key field. I would like to run the Table Maintenance Generator on the first table in SE11 and be able to maintain both table data at the same time in SM30.
    How can I do that without any ABAP programming? Should I use Append or Include structure or else?
    Thank you for giving as much detail as possible.
    Regards,
    Sylvain

    Hi,
    You cant do it w/t abap programing.
    You can code in "EVENT" to achive the same.
    Open table maintainance generator of first table through se56 or se11.
    follow the path: environment>Modification>Event.
    Select sutaible event from drop down like Before Save... and do coding.
    In this way data will be saved in second table automatically when you save in first table.
    In case of any query, please revert.
    regards,
    Dhan

  • How do I count/add fields with numbers and fields with letters?

    This is an attendance calendar I'm making for my work.
    Cells in CLIENT A column will be marked with either a number ( >0, indicating how many hours attended) or a letter (A = absent, H = Holiday).
    I need 2 formulas/scripts I suppose:
    1) I would like cell DP1 to represent how many cells in the CLIENT A column are marked only with a number >0 -indicating how many days were attended, not how many total hours there are.
    2) I would like cell DA1 to represent how many cells in the CLIENT A column are marked only with the letter A -indicating how many days were not attended.

    Let's say there are 20 fields in the column. In that case you can use these scripts:
    Custom calculation script for "DPA"
    var total = 0;
    for (var i=1; i<=20; i++) {
        var v = +this.getField("CA"+i).value;
        if (isNaN(v)==false && v>0)
            total++;
    event.value = total;
    Custom calculation script for "DPB"
    var total = 0;
    for (var i=1; i<=20; i++) {
        var v = this.getField("CA"+i).value;
        if (v=="A")
            total++;
    event.value = total;

  • Problem with syncing count of plays with itunes

    Hi everybody,
    Recently I lost my laptop (it has been stolen). Also i lost all data on harddrive including itunes libary. Thing is, all my music was on iPhone. Some of albums I bought in iTunes store, some of them imported from cd's. There was lots of stuff. When I bought another laptop, and connected my iPhone it says all data will be deleted from iPhone and replaced with data from itunes library. So I didn't want to do this, because i don't want to loose my count of plays, my playlists, etc, btw it would take ages to import all this music again, not mentioned about albums from itunes store!
    So i found this program - SHAREPOD - it helped me to copy all this data back to the computer, I copied that to iTunes Media folder and everything is in iTunes, so that's fine (apart from couple missing album artworks). But now, when I try to sync my iPhone with iTunes, it says the same message - all your data will be repleaced with itunes library. But I don't want it to repleace that, I just want to sync iPhone with that library. I really want to keep my count of plays for every song.
    Btw. the same problem is with programs, it wants to repleace that with itunes library, I've got more than 100 apps, most of them paid and i don't want to loose them, but I want it to work exactly the same as it worked previously.
    For me it's a really huge issue, that basically sync works only one way...
    Please help.

    You will have to sync and with any luck it won't try to re-sync all your music. In iTunes if you right click on your phone under the devices list you can select "transfer purchases" and that will move all your apps to iTunes.
    TuneUp companion is a great program that runs along side of iTunes that will fix all your track info and put the album artwork in the info.

  • 30p with a Canon XA10 - need help with Final Cut 7 "FIELD DOMINANCE" setting and an explanation of "drop frames". Thank you!!

    I shot footage using a Canon XA10 and there are issues with the HD quality not looking as crisp as it should.  I am trying to make sure the settings in Final Cut are right.  Need help confirming what should be in "Field Dominance" --- have seen discussions about making sure it's set to "none" but I'm confused as to what to do. 
    Also someone suggested I use "drop frames" to change from 30p to 24p within Final Cut.  He couldn't explain how to do it so any input appreciated as well as any thoughts on whether this is a good option to try.

    If you're shooting 30p, field dominance should be set to none.   Since you need to use log and transfer to bring this material in to fcp, I would assume it would be set correctly automatically.  Are you sure you've set the camera properly?
    Drop frames will not change 30 p to 24p.   Dropframe timecode simply refers to the number assigned to each frame which drops an occasional number (not any frames) so the timecode duration is the actual duration, since 30p videoi is actually 29.97 frames per second which each frame assigned a timecode number. 
    This is very basic video stuff and requires some basic knowledge of video.  Wikipedia is a pretty good resource for much of this stuff plus there are lots of great resources on the web.  Look up interlaced and progressive video, 24p and 30p. 
    And as far as judging quality, you can only get an accurate view of the quality in fcp when you have a video card attached to a video monitor.  The viewer and canvas are only an approximation of what the quality is.  Minimally, set the canvas or viewer to 100% to get a better approximation of the quality. 

  • Problem with multiple counter plan containing running hrs and no of months

    Hey gurus,
    In my project the preventive maintenance of compressor is such that it is performed after 500 hrs or 6 months whichever comes first. Now i ve created a cycle set cosisting of 500 hrs and 6 months. In the multiple counter plan i ve assigned a counter to the plan for calculating 500 hrs and chosen the link as OR. I scheduled the plan and given the start date as 01.05.09. Now I am facing the following problem:
    Suppose my counter value reaches the 500 mark on 01.08.09. Now a maintenance order is generated. My client now wants that the next order should be generated after the counter reading reaches 1000 or the date reaches 01.02.10, ie, the order should be generated for next 500hrs or NEXT 6 MONTHS from
    the date of completion of first cycle, whichever comes first.
    Pls help....
    Regards,
    Abhishek

    Hi
    If u have scheduled ur plan according to cycle set. It will take the Point of contact as 6 months.
    OK
    Ex : Cycle set : 500 hrs and 6 months, maintained OR functions
    i have entered the measurement reading as 500.. thats why, it gives the call for todays date...
    see the next date will be after 6 months... If u update the measuring point only, it will open a order... otherwise.. once u have scheduled it for 6 months.. once in 6 months it will give a order...
    1     11.05.2009               0     New start  Save to call
    2     07.11.2009     07.11.2009          0     Scheduled  Hold
    3     06.05.2010     06.05.2010          0     Scheduled  Hold
    4     02.11.2010     02.11.2010          0     Scheduled  Hold
    5     01.05.2011     01.05.2011          0     Scheduled  Hold
    6     28.10.2011     28.10.2011          0     Scheduled  Hold
    7     25.04.2012     25.04.2012          0     Scheduled  Hold
    Schedule for a long period.. u will be able to understand the scenario...
    - Pithan

  • Help with listing records from two tables

    Hi: I have two tables joined by the first field. The field is primary key in first table. Need help listing records from both tables with each record one line/record.
    create table EVENTS (
    event_key varchar2(64) primary key,
    event_description varchar2(64),
    create_time int
    create table EVENT_UPDATES (
    event_key varchar2(64) NOT NULL ,
    update_description varchar2(64),
    update_time int
    insert into EVENTS values('Event1', 'This is event1', 1);
    insert into EVENT_UPDATES values('Event1', 'Ticket created', 3);
    insert into EVENT_UPDATES values('Event1', 'Event cleared', 10);
    insert into EVENTS values('Event2', 'This is event2', 4);
    insert into EVENT_UPDATES values('Event2', 'Ticket created', 6);
    insert into EVENT_UPDATES values('Event2', 'Event cleared', 8);I want to print each record in EVENTS table as one line and corresponding records in EVENT_UPDATES as one line/record like this
    Event1   1     This is event1
                3     Ticket created
                10   Event cleared
    Event2   4     This is event2
                6     Ticket created
                8     Event clearedTIA
    Ravi

    select  case weight
              when 1 then event_key
            end key,
            time_val,
            description
      from  (
              select  event_key,
                      create_time time_val,
                      event_description description,
                      1 weight
                from  events
             union all
              select  event_key,
                      update_time,
                      update_description,
                      2 weight
                from  event_updates
      order by event_key,
               weight
    KEY          TIME_VAL DESCRIPTION
    Event1              1 This is event1
                        3 Ticket created
                       10 Event cleared
    Event2              4 This is event2
                        6 Ticket created
                        8 Event cleared
    6 rows selected.
    SQL> SY.

  • Table with a huge size. With big fields... should be in a separated table?

    Hi.
    Consider the following table
    id_foo num_doc_foo pages_foo pdf_foo .. etc
    imagine that the table has millions of records, and a total size of 4GB or more.
    im collecting data for build a statistical form, but the query takes forever, althow analizing the query all checks out.
    My question is, the size of the table might influence the query performance?
    Should i create a separated table to collect the values i want, and keep the previous table to save the data (the pdf_data documents are huge).
    Resuming what im saying.
    A table for the huge data fields (with a big size), and another table that connects to the previous one, but with smaller data, data for generating reports, etc.
    What do u think? Does it makes sence?
    I work with oracle 9.2x , and can't upgrade.
    Cheers.

    don't remember exact details for 9.2, but I believe that oracle stores the LOB separate from the rest of the table, if it's over a certain threshold. so, if the pdfs are large enough, they aren't really stored with the table data, so reporting queries won't be affected. check the manual for how LOB storage works, and then store the pdfs in a separate table if needed.

  • Want to Join two tables with cursors

    Can anyone tell me how to join two tables only by cursors.
    Not with:
    1.Joining condition
    2.Procedure etc.
    Only cursors with passing parameters.
    Sowmya

    This is my assignment. I want to get the matching records from both tables. I have pk, fk for both tables for deptno.Can I pass parameter for this.
    dept table:
    deptno deptname
    10 sales
    20 Erp
    30 hr
    40     marketing
    emp table:
    Empno deptno Name
    1 10 lee
    2 20 hans
    3 10 peter
    4 30 james
    5 30 king
    Output should be:
    deptno empname empno deptname
    10 lee 1 sales
    10 peter 3 erp
    30 james 4 hr
    30 king 5 marketing

Maybe you are looking for