Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Other Discussions
  3. The Weird and The Wonderful
  4. Would you like to buy an IsNull ?

Would you like to buy an IsNull ?

Scheduled Pinned Locked Moved The Weird and The Wonderful
databasesql-serversysadminquestion
9 Posts 5 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • P Online
    P Online
    PIEBALDconsult
    wrote on last edited by
    #1

    (SQL Server 2008 R2.) (CASE WHEN cTT.Total IS NOT NULL THEN cTT.Total ELSE 0 END) as 'Total_Total' A dozen of these in a view... :sigh:

    D A K J 4 Replies Last reply
    0
    • P PIEBALDconsult

      (SQL Server 2008 R2.) (CASE WHEN cTT.Total IS NOT NULL THEN cTT.Total ELSE 0 END) as 'Total_Total' A dozen of these in a view... :sigh:

      D Offline
      D Offline
      dan sh
      wrote on last edited by
      #2

      What exactly are they selling? Give me the URL. Please. I would like to buy that Mars rover for null. :)

      "Bastards encourage idiots to use Oracle Forms, Web Forms, Access and a number of other dinky web publishing tolls.", Mycroft Holmes[^]

      P 1 Reply Last reply
      0
      • D dan sh

        What exactly are they selling? Give me the URL. Please. I would like to buy that Mars rover for null. :)

        "Bastards encourage idiots to use Oracle Forms, Web Forms, Access and a number of other dinky web publishing tolls.", Mycroft Holmes[^]

        P Online
        P Online
        PIEBALDconsult
        wrote on last edited by
        #3

        I'm sure you can just go pick one up; there's no security around.

        1 Reply Last reply
        0
        • P PIEBALDconsult

          (SQL Server 2008 R2.) (CASE WHEN cTT.Total IS NOT NULL THEN cTT.Total ELSE 0 END) as 'Total_Total' A dozen of these in a view... :sigh:

          A Offline
          A Offline
          AspDotNetDev
          wrote on last edited by
          #4

          PIEBALDconsult wrote:

          Total_Total

          What's the second "total" for? Did the programmer have total recall?

          Thou mewling ill-breeding pignut!

          P D 2 Replies Last reply
          0
          • A AspDotNetDev

            PIEBALDconsult wrote:

            Total_Total

            What's the second "total" for? Did the programmer have total recall?

            Thou mewling ill-breeding pignut!

            P Online
            P Online
            PIEBALDconsult
            wrote on last edited by
            #5

            Normal people might call it a "Grand total". :rolleyes:

            1 Reply Last reply
            0
            • P PIEBALDconsult

              (SQL Server 2008 R2.) (CASE WHEN cTT.Total IS NOT NULL THEN cTT.Total ELSE 0 END) as 'Total_Total' A dozen of these in a view... :sigh:

              K Offline
              K Offline
              KP Lee
              wrote on last edited by
              #6

              There are plenty of dumb things done in SQL. Could be the coder never heard of ISNULL. Could be he came from a programming background. Could be he doesn't realize ISNULL is more efficient than a case statement. Could be a misapplication of "don't execute a function in a where clause" rule. Could be he forgot about ISNULL. Could be he's in the "Let's obsfucate this code as much as possible" club. At least it isn't SUM(CASE WHEN cTT.Total IS NOT NULL THEN cTT.Total ELSE 0 END) as 'Total_Total'

              P 1 Reply Last reply
              0
              • K KP Lee

                There are plenty of dumb things done in SQL. Could be the coder never heard of ISNULL. Could be he came from a programming background. Could be he doesn't realize ISNULL is more efficient than a case statement. Could be a misapplication of "don't execute a function in a where clause" rule. Could be he forgot about ISNULL. Could be he's in the "Let's obsfucate this code as much as possible" club. At least it isn't SUM(CASE WHEN cTT.Total IS NOT NULL THEN cTT.Total ELSE 0 END) as 'Total_Total'

                P Online
                P Online
                PIEBALDconsult
                wrote on last edited by
                #7

                KP Lee wrote:

                At least it isn't ...

                I think that's in a few other places. :sigh: This is an improvement over some earlier code by the same guy that is something like:

                SELECT
                (SELECT COUNT(*) FROM T WHERE ... ) A ,
                (SELECT COUNT(*) FROM T WHERE ... ) B ,
                (SELECT COUNT(*) FROM T WHERE ... ) C ,
                ...

                1 Reply Last reply
                0
                • A AspDotNetDev

                  PIEBALDconsult wrote:

                  Total_Total

                  What's the second "total" for? Did the programmer have total recall?

                  Thou mewling ill-breeding pignut!

                  D Offline
                  D Offline
                  dan sh
                  wrote on last edited by
                  #8

                  Nope. It's a symbol for Total/scoreTotal. He's calculating GPA or something. :)

                  "Bastards encourage idiots to use Oracle Forms, Web Forms, Access and a number of other dinky web publishing tolls.", Mycroft Holmes[^]

                  1 Reply Last reply
                  0
                  • P PIEBALDconsult

                    (SQL Server 2008 R2.) (CASE WHEN cTT.Total IS NOT NULL THEN cTT.Total ELSE 0 END) as 'Total_Total' A dozen of these in a view... :sigh:

                    J Offline
                    J Offline
                    Jorgen Andersson
                    wrote on last edited by
                    #9

                    Maybe he wants the code to be ANSI compatible. In which case I would use COALESCE.

                    People say nothing is impossible, but I do nothing every day.

                    1 Reply Last reply
                    0
                    Reply
                    • Reply as topic
                    Log in to reply
                    • Oldest to Newest
                    • Newest to Oldest
                    • Most Votes


                    • Login

                    • Don't have an account? Register

                    • Login or register to search.
                    • First post
                      Last post
                    0
                    • Categories
                    • Recent
                    • Tags
                    • Popular
                    • World
                    • Users
                    • Groups