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

  • SEARCH
  • Home
  • 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 7543495
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T08:26:35+00:00 2026-05-30T08:26:35+00:00

This is my base query select distinct a.projects , case when(billing_fy!=0) then(select round(((sum(cost_project)/(sum(billing_fy)/((10/12)*365)))),2) from

  • 0

This is my base query

select distinct a.projects , case when(billing_fy!=0)
then(select round(((sum(cost_project)/(sum(billing_fy)/((10/12)*365)))),2) 
     from table1 b      
     where a.projects = b.projects 
     group by projects)
else 0 end as "WIP days outstanding"
from table1 a

and it produces the following output

Projects                        WIP days outstanding
History - AURANGABAD - NASIK    0
History - PUNE - MUMBAI         0
History - NASIK - MUMBAI        89.92
History - SASAGRAM - MUMBAI     0
History - SASAGRAM - MUMBAI     1386.52
History - AURANGABAD - MUMBAI   83.25

Now what I need is to display all rows except the 4th row. The reason why I’m using a case statement in the first place is because if I did (the billing_fy!=0 clause is to prevent an error caused by dividing by 0)

select projects,
round(((sum(cost_project)/(sum(billing_fy)/((10/12)*365)))),2) as "WIP days outstanding"
from table1
where billing_fy!=0
group by projects;

I would get

Projects                        WIP days outstanding
History - SASAGRAM - MUMBAI     1386.52
History - NASIK - MUMBAI        89.92
History - AURANGABAD - MUMBAI   83.25

but I need to show for the other 2 places as well

History - AURANGABAD - NASIK    0
History - PUNE - MUMBAI         0

This query only displays the row I don’t want.

select distinct a.projects , case when(billing_fy!=0)
then(select round(((sum(cost_project)/(sum(billing_fy)/((10/12)*365)))),2) from table1 b     where a.projects = b.projects group by projects)
else 0 end as "WIP days outstanding"
from table1 a
where (projects='History - SASAGRAM - MUMBAI' AND billing_fy=0);

and gives the output as expected

Projects                        WIP days outstanding
History - SASAGRAM - MUMBAI     0

Now comes my question. Is there a way in SQL to negate the WHERE clause? Like in C++ I would just have to use a not operator in front of the clause to negate it. Because basically, I want to display all rows EXCEPT the row above.

Right now, I’ve solved my problem of displaying all rows except the row I don’t want by using the following code

select distinct a.projects , case when(billing_fy!=0)
then(select round(((sum(cost_project)/(sum(billing_fy)/((10/12)*365)))),2) from table1 b   where a.projects = b.projects group by projects)
else 0 end as "WIP days outstanding"
from table1 a
where projects not in ('History - SASAGRAM - MUMBAI') and billing_fy!=0
union all
select distinct a.projects , case when(billing_fy!=0)
then(select round(((sum(cost_project)/(sum(billing_fy)/((10/12)*365)))),2) from table1 b   where a.projects = b.projects group by projects)
else 0 end as "WIP days outstanding"
from table1 a
where projects not in ('History - SASAGRAM - MUMBAI') and billing_fy=0
union all
select distinct a.projects , case when(billing_fy!=0)
then(select round(((sum(cost_project)/(sum(billing_fy)/((10/12)*365)))),2) from table1 b    where a.projects = b.projects group by projects)
else 0 end as "WIP days outstanding"
from table1 a
where projects='History - SASAGRAM - MUMBAI' and billing_fy!=0;

And this produces the required output

Projects                         WIP days outstanding
History - NASIK - MUMBAI         89.92
History - AURANGABAD - MUMBAI    83.25
History - AURANGABAD - NASIK     0
History - PUNE - MUMBAI          0
History - SASAGRAM - MUMBAI      1386.52

This is just a shabby way of doing it, and I’d like to know if it is possible to just negate the WHERE clause, or some “neater” alternative to do what I want to do.

Thanks !!

P.S. I use SQL Developer and Oracle 11g (just in case someone asks)

EDIT Input Values as requested

Projects                      Cost_Project  Billing_FY
History - NASIK - MUMBAI      65696067.99   54937478.46
History - NASIK - MUMBAI      41385613.61   151909546.44
History - NASIK - MUMBAI      18029488.91   216353866.92
History - AURANGABAD - MUMBAI 33191393.23   57073935.95
History - AURANGABAD - MUMBAI 52681451.68   139055661.74
History - AURANGABAD - MUMBAI 74576522.31   390092578.24
History - PUNE - MUMBAI       0             0
History - PUNE - MUMBAI       0             0
History - PUNE - MUMBAI       0             0
History - SASAGRAM - MUMBAI   107540114.08  40653734.06
History - SASAGRAM - MUMBAI   209167760.1   28823862.66
History - SASAGRAM - MUMBAI   0             0
History - AURANGABAD - NASIK  0             0
History - AURANGABAD - NASIK  0             0
History - AURANGABAD - NASIK  0             0
  • 1 1 Answer
  • 0 Views
  • 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-30T08:26:37+00:00Added an answer on May 30, 2026 at 8:26 am

    If I’m reading your question correctly, what you want is the not operator:

    select distinct a.projects , case when(billing_fy!=0)
    then(select round(((sum(cost_project)/(sum(billing_fy)/((10/12)*365)))),2) 
    from table1 b     
    where a.projects = b.projects group by projects)
    else 0 end as "WIP days outstanding"
    from table1 a
    where not (projects='History - SASAGRAM - MUMBAI' AND billing_fy=0);
    

    As @ShannonSeverance points out, this will cause a problem if you have null values in either field, as not (false and null) evaluates to null, which will be treated as false. If you need to make this null safe, so that it only excludes a row that has both of those values, you’d need to do something like this:

    select distinct a.projects , case when(billing_fy!=0)
    then(select round(((sum(cost_project)/(sum(billing_fy)/((10/12)*365)))),2) 
    from table1 b
    where a.projects = b.projects group by projects)
    else 0 end as "WIP days outstanding"
    from table1 a
    where (not (projects='History - SASAGRAM - MUMBAI' AND billing_fy=0))
          or projects is null 
          or billing_fy is null;
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

So I'm trying to execute this query: SELECT r.refID AS rID, avgrat FROM rcc
My scenario is this: I have a base NHibernate query to run of the
Consider this - a base class A, class B inheriting from A, class C
I have a class that inherits from a base class (this contains a lot
I've got a sub-select in a query that looks something like this: left outer
I have the following query: SELECT Base.ReportDate, Base.PropertyCode, Base.FirstName, Base.MiddleName, Base.LastName, Person.FirstName, Person.MiddleName, Person.LastName
Consider the following SQL Server 2005/2008 query: Select [UID], [DESC] From SomeTable Order By
I have a query that looks like: select distinctrow company.* from company, contact, address,
I want to combine the following queries into a single query: SELECT val FROM
I need to extend a class, which is encapsulated in a closure. This base

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.