Sign Up

❇️ OrclQA.Com is a question and answer forum for programmers.
❇️ Here anyone can ask questions and anyone can answer to help others.
❇️ It hardly takes a minute to sign up and it is 100% FREE.

Have an account? Sign In


Have an account? Sign In Now

Sign In

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

Sorry, you do not have a permission to ask a question, You must login to ask question.

Forgot Password?

Need An Account, Sign Up Here
Sign InSign Up

OrclQA.Com

OrclQA.Com Logo OrclQA.Com Logo

OrclQA.Com Navigation

  • Ask Question
  • Write a Tutorial
  • Online Courses
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Blog
  • New Questions
  • Tutorials
    • Oracle
    • Oracle Apex
    • Python
  • Tags
  • Users
  • Badges & Points
  • Image to Base64
  • PL/SQL Beautifier
  • Ask Question
  • Write a Tutorial
  • Online Courses
Mac
Mac

Mac

  • 4 Questions
  • 1 Answer
  • 0 Best Answers
  • 40 Points
View Profile
  • 0
MacContributor
Asked: July 1, 20222022-07-01T10:49:17+05:30 2022-07-01T10:49:17+05:30

Formatting data in an IR using SQL

  • 0
Advertisement

Hi all,

I hope you can help.

I have SQL which is the data source for an IG. The SQL aggregates hours spent working on specific tasks and gather info from other tables in sub-queries. The duration is stored in minutes but I want to display the duration in hh: mm format. I have done this successfully for the primary query, however, the sub-queries fail with "ORA-00921: unexpected end of SQL command". The query is below.

Advertisement

If I remove the trim()... from the sub-query it works fine but the format of the duration is just in minutes rather than hh:mm.

I would appreciate any help you might be able to offer.

This code fails

Advertisement

select c.week_starting,
trim(to_char(trunc(sum(c.DUR_IN_MINS) / 60), '9')) || ':' || trim(to_char(trunc(mod(abs(sum(c.DUR_IN_MINS)), 60)), '09')) AS CLIENT_HHMM,
(
select trim(to_char(trunc(sum(r.DUR_IN_MINS) / 60), '9')) || ':' || trim(to_char(trunc(mod(abs(sum(r.DUR_IN_MINS)), 60)) AS ACT_HHMM
from FPO_CLIENT_REL_ACT r
where c.week_starting = r.week_starting
)
from FPO_SECT_A_PRO_PRAC c
group by c.week_starting

 

 

Advertisement

THIS WORKS FINE

 


select c.week_starting,
trim(to_char(trunc(sum(c.DUR_IN_MINS) / 60), '9')) || ':' || trim(to_char(trunc(mod(abs(sum(c.DUR_IN_MINS)), 60)), '09')) AS CLIENT_HHMM,
(
select r.DUR_IN_MINS AS ACT_HHMM
from FPO_CLIENT_REL_ACT r
where c.week_starting = r.week_starting
)
from FPO_SECT_A_PRO_PRAC c
group by c.week_starting

apexsql
  • 1
  • 30
  • 0
  • 0
  • Share
    • Share on Facebook
    • Share on Twitter
    • Share on LinkedIn
Answer
    Advertisement

    1 Answer

    1. APEXUSER (nobody)

      APEXUSER (nobody)

      • 0 Questions
      • 10 Answers
      • 0 Best Answers
      • 79 Points
      View Profile
      APEXUSER (nobody) Professional
      2022-07-05T14:45:35+05:30Added an answer on July 5, 2022 at 2:45 pm

      Hey..

      Hope You Are Doing Great!

      Use This Query

       

      SELECT TRUNC(minutes/60) || ':' || (minutes - TRUNC(minutes/60)*60) FROM abcd a;

       

       

      Hope You Get Your Answer

      Thanks!

      • 0
      • Share
        Share
        • Share on Facebook
        • Share on Twitter

    You must login to add an answer.

    Forgot Password?

    Advertisement

    Sidebar

    Ask Question
    Write a Tutorial
    Advertisement

    Recent Blog Posts

    • Vinish

      Oracle LENGTH()

    • Vinish

      Oracle INSTR() Function

    • Vinish

      Oracle INITCAP() Function

    • Vinish

      Oracle Concat

    • Vinish

      Oracle CHR Function

    Advertisement
    Advertisement

    Explore

    • Home
    • Blog
    • New Questions
    • Tutorials
      • Oracle
      • Oracle Apex
      • Python
    • Tags
    • Users
    • Badges & Points
    • Image to Base64
    • PL/SQL Beautifier

    Creative Commons License
    This work is licensed under a Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International License.
    © 2021 OrclQA.Com. All Rights Reserved.
    Privacy Policy - About Us