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. Database & SysAdmin
  3. Database
  4. sql ROLLUP

sql ROLLUP

Scheduled Pinned Locked Moved Database
databasetutorialquestion
4 Posts 3 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.
  • B Offline
    B Offline
    byka
    wrote on last edited by
    #1

    I am using ROLLUP build in function SELECT Product,COUNT(Total), FROM myTable Group BY TOTAL with ROLLUP Percent - is calculated %. when I run it for product I am getting NULL in ROLLUP row. How to I replace with word? so it looks like this TOTAL 23 100 instead of NULL 23 100

    R 1 Reply Last reply
    0
    • B byka

      I am using ROLLUP build in function SELECT Product,COUNT(Total), FROM myTable Group BY TOTAL with ROLLUP Percent - is calculated %. when I run it for product I am getting NULL in ROLLUP row. How to I replace with word? so it looks like this TOTAL 23 100 instead of NULL 23 100

      R Offline
      R Offline
      R Giskard Reventlov
      wrote on last edited by
      #2

      SELECT
      case when (Grouping(Product) = 1) then 'Total'
      else Product
      end Product,
      COUNT(Product) as Counter
      FROM myTable
      Group BY Product with ROLLUP

      "If you think it's expensive to hire a professional to do the job, wait until you hire an amateur." Red Adair. nils illegitimus carborundum me, me, me

      M 1 Reply Last reply
      0
      • R R Giskard Reventlov

        SELECT
        case when (Grouping(Product) = 1) then 'Total'
        else Product
        end Product,
        COUNT(Product) as Counter
        FROM myTable
        Group BY Product with ROLLUP

        "If you think it's expensive to hire a professional to do the job, wait until you hire an amateur." Red Adair. nils illegitimus carborundum me, me, me

        M Offline
        M Offline
        Mycroft Holmes
        wrote on last edited by
        #3

        Well I'll be buggered, I did not know the keyword rollup, thank you have 5.

        Never underestimate the power of human stupidity RAH

        R 1 Reply Last reply
        0
        • M Mycroft Holmes

          Well I'll be buggered, I did not know the keyword rollup, thank you have 5.

          Never underestimate the power of human stupidity RAH

          R Offline
          R Offline
          R Giskard Reventlov
          wrote on last edited by
          #4

          I'll take the 5, thank you, but pass on the buggery, if you don't mind. :-)

          "If you think it's expensive to hire a professional to do the job, wait until you hire an amateur." Red Adair. nils illegitimus carborundum me, me, me

          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