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 8975851
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T18:59:03+00:00 2026-06-15T18:59:03+00:00

Can anyone help me with the proper syntax for a case statement using SQL

  • 0

Can anyone help me with the proper syntax for a “case” statement using SQL Plus?

Select 
sum(case "REQUEST AGE" when >= 60 then 1 else 0) as "60+ Days",
sum(case "REQUEST AGE"  when >= 30 and case when "REQUEST AGE" < 60 then 1 else 0) as "30-    60 Days",
sum (case "REQUEST AGE" when < 30 then 1 else 0) as "Less Than 30 Days",
"SECTOR"
FROM Schema.APPDATA
Where Schema.APPDATA."SECTOR" like '%X%'

I’m relatively new to SQL and I have never written such a query. I would like a sum of a case when the column request age is greater than 60, between 30 and 60 and less than 30 as 3 columns grouped by column sector

  • 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-06-15T18:59:04+00:00Added an answer on June 15, 2026 at 6:59 pm

    You need to use CASE WHEN [expression]... THEN rather than CASE [variable] WHEN [value] THEN ... :

    Select 
    sum(case WHEN "REQUEST AGE" >= 60 then 1 else 0 end) as "60+ Days",
    ....
    

    Also, it seems that count is more appropriate in your case than sum – you won’t need else at all.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I cant seem to grasp the proper concepts of a factory. Can anyone help
Can anyone help me to convert this to proper JavaScript? <script>var datePostForAll = &#39;<div
Can anyone help me with a simple sql tag please?? Here's what I want:
Can anyone help - this is driving me mad. I am calling a mysql
Can Anyone help me why x2 prints zero. I guess because of floating point
Can anyone help me how to split /explode verse format to 3 parts? The
Can anyone help me to get good WordPress interview questions and answers. Any link
Can anyone help me in converting scalar type of openCV to basic types like
can anyone help me for the exercise 12.5 of Jason Hickey's book? Basically, the
Can anyone help me with the script to refresh the page once . I

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.