Solved

Number Format

Posted on 2016-09-16
1
44 Views
Last Modified: 2016-09-16
I have the following code that will give me the sum of the last hours worked in a 12 month period.
(SELECT sum(prt.hours)
       FROM prod.prtime prt
       WHERE prt.tr_date BETWEEN TRUNC (ADD_MONTHS (SYSDATE, -13), 'MM')  
       AND TRUNC (LAST_DAY (ADD_MONTHS (SYSDATE, -1))+1) ) HOURS_WORKED

I need to have the Hours Worked field formatted to 6 spaces.
I don't need the decimal values, but still need everything to be a total of 6 spaces.

Currently, I'm getting values like:
1961.61
1984
1762.1
672
80

I need to have the results look like:
1961
1984
1762
672
0
Comment
Question by:metalteck
1 Comment
 
LVL 34

Accepted Solution

by:
johnsone earned 500 total points
ID: 41802160
rpad(trunc(sum(prt.hours)), 6)
0

Featured Post

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Background In several of the companies I have worked for, I noticed that corporate reporting is off loaded from the production database and done mainly on a clone database which needs to be kept up to date daily by various means, be it a logical…
This article describes how to use the timestamp of existing data in a database to allow Tableau to calculate the prior work day instead of relying on case statements or if statements to calculate the days of the week.
This video explains at a high level with the mandatory Oracle Memory processes are as well as touching on some of the more common optional ones.
This video shows how to Export data from an Oracle database using the Datapump Export Utility.  The corresponding Datapump Import utility is also discussed and demonstrated.

758 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now