Solved

Number Format

Posted on 2016-09-16
1
59 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

MIM Survival Guide for Service Desk Managers

Major incidents can send mastered service desk processes into disorder. Systems and tools produce the data needed to resolve these incidents, but your challenge is getting that information to the right people fast. Check out the Survival Guide and begin bringing order to chaos.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
pivot rows to columns 1 34
average of calculation (TSQL) 4 26
Procedure syntax 5 38
SQL Syntax Grouping Sum question 7 24
I remember the day when someone asked me to create a user for an application developement. The user should be able to create views and materialized views and, so, I used the following syntax: (CODE) This way, I guessed, I would ensure that use…
Composite queries are used to retrieve the results from joining multiple queries after applying any filters. UNION, INTERSECT, MINUS, and UNION ALL are some of the operators used to get certain desired results.​
Via a live example show how to connect to RMAN, make basic configuration settings changes and then take a backup of a demo database
This videos aims to give the viewer a basic demonstration of how a user can query current session information by using the SYS_CONTEXT function

856 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