Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 495485
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T05:35:52+00:00 2026-05-13T05:35:52+00:00

I want to create an view in Oracle which calculates an "utilization rate in

  • 0

I want to create an view in Oracle which calculates an "utilization rate in percent".

AS SELECT
  sw.SWITCH_ID,
  sw.ASSET_ID,
  sw.SYSTEMNAME,
  sw.MAX_INSTALLABLE_PORTS,
  sw.INSTALLED_PORTS,
  sw.USED_PORTS,
  (sw.INSTALLED_PORTS/sw.MAX_INSTALLABLE_PORTS)*100 AS UTIL_INSTALLED_PORTS,
  sw.RES_INFRASTRUCTURE_PORTS,
  sw.USED_INFRASTRUCTURE_PORTS,
  sw.FREE_INFRASTRUCTURE_PORTS,
  (sw.INSTALLED_PORTS/sw.MAX_INSTALLABLE_PORTS)*100 AS UTIL_INFRASTRUCTURE_PORTS,
  sw.RESERVED_DEVICE_PORTS,
  sw.USED_DEVICE_PORTS,
  sw.FREE_DEVICE_PORTS,
  (sw.FREE_DEVICE_PORTS/sw.RESERVED_DEVICE_PORTS)*100 AS UTIL_DEVICE_PORTS,
  sw.RUN_DATE

Problem: sometimes sw.INSTALLED_PORTS or sw.MAX_INSTALLABLE_PORTS can be NULL (same for other UTIL Rows).

Is there any nice way to do something like:

if (sw.INSTALLED_PORTS or sw.MAX_INSTALLABLE_PORTS == null) 
      UTIL_INSTALLABLE_PORTS = null 
else (sw.INSTALLED_PORTS/sw.MAX_INSTALLABLE_PORTS)*100 AS UTIL_INSTALLABLE_PORTS,
  • 1 1 Answer
  • 1 View
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-13T05:35:52+00:00Added an answer on May 13, 2026 at 5:35 am

    Divizion by NULL is not the same as divizion by zero (as you reference the problem in the title).

    select 1/null from dual = null
    select null/null from dual = null

    So you’ll automatically get what you want by (sw.INSTALLED_PORTS/sw.MAX_INSTALLABLE_PORTS)*100.

    I think, the problem is when sw.MAX_INSTALLABLE_PORTS is zero. In this case you can use the following:

    case
      when sw.MAX_INSTALLABLE_PORTS = 0 then null
      else (sw.INSTALLED_PORTS/sw.MAX_INSTALLABLE_PORTS)*100
    end
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want to create grid view which contains CheckBoxes dynamically in my winform application.
I want to create indexed view with such t-sql: Select Table1_ID, cast(CONVERT(varchar(8), t2.Object_CreationDate, 112)AS
I want to create a view for this sql statement which previously works fine.
I want to create view in which when user use in portrait mode then
I want to create a view which has one button that add edit text
Can i create an oracle View with a DB generated Primary Key? I want
I want to create view with 52 square or button (for 52 week in
I want to create a view that contains two forms with their submit buttons.
I want to create a view from the following two tables: Entry: entry_id entry_date
I want to create a view in a one-to-many relation. Here are my relations:

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.