SitePoint Sponsor

User Tag List

Results 1 to 3 of 3

Hybrid View

  1. #1
    SitePoint Guru
    Join Date
    Oct 2011
    Posts
    658
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Update with + Operation

    Hi..

    I had encountered problem in my update code:

    Code:
    UPDATE kanban_checker_doz SET
    virtual_doz = (count_doz_chemical_weighing + count_doz_compounding + count_doz_extrusion
    + count_doz_forming);
    it did not work when I have only data in count_doz_chemical_weighing and the other is NULL.

    I also tried this code but still the virtual_doz = NULL.

    Code:
    UPDATE kanban_checker_doz SET
    virtual_doz = ((NULLIF(count_doz_chemical_weighing, 0)) + (NULLIF(count_doz_compounding, 0)) + (NULLIF(count_doz_extrusion, 0))
    + (NULLIF(count_doz_forming, 0)));
    Thank you

  2. #2
    SitePoint Guru
    Join Date
    Jan 2004
    Location
    Uppsala, sverige
    Posts
    697
    Mentioned
    2 Post(s)
    Tagged
    1 Thread(s)
    Code:
    update kanban_checker_doz 
       set virtual_doz = coalesce(count_doz_chemical_weighing, 0) + 
                         coalesce(count_doz_compounding,0) + 
                         coalesce(count_doz_extrusion,0) + 
                         coalesce(count_doz_forming,0)

  3. #3
    SitePoint Guru
    Join Date
    Oct 2011
    Posts
    658
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thank you it works


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •