MySQL String Exercises: Display leading zeros before maximum and minimum salary
MySQL String: Exercise-4 with Solution
Write a query to display leading zeros before maximum and minimum salary.
Sample table: jobs
Code:
SELECT job_id, LPAD( max_salary, 7, '0') ' Max Salary',
LPAD( min_salary, 7, '0') ' Min Salary'
FROM jobs;
Sample Output:
job_id Max Salary Min Salary AD_PRES 0040000 0020000 AD_VP 0030000 0015000 AD_ASST 0006000 0003000 FI_MGR 0016000 0008200 FI_ACCOUNT 0009000 0004200 AC_MGR 0016000 0008200 AC_ACCOUNT 0009000 0004200 SA_MAN 0020000 0010000 SA_REP 0012000 0006000 PU_MAN 0015000 0008000 PU_CLERK 0005500 0002500 ST_MAN 0008500 0005500 ST_CLERK 0005000 0002000 SH_CLERK 0005500 0002500 IT_PROG 0010000 0004000 MK_MAN 0015000 0009000 MK_REP 0009000 0004000 HR_REP 0009000 0004000 PR_REP 0010500 0004500
MySQL Code Editor:
Have another way to solve this solution? Contribute your code (and comments) through Disqus.
Previous:Write a query to get the details of the employees where the length of the first name greater than or equal to 8.
Next:Write a query to append '@example.com' to email field.
What is the difficulty level of this exercise?
- New Content published on w3resource:
- HTML-CSS Practical: Exercises, Practice, Solution
- Java Regular Expression: Exercises, Practice, Solution
- Scala Programming Exercises, Practice, Solution
- Python Itertools exercises
- Python Numpy exercises
- Python GeoPy Package exercises
- Python Pandas exercises
- Python nltk exercises
- Python BeautifulSoup exercises
- Form Template
- Composer - PHP Package Manager
- PHPUnit - PHP Testing
- Laravel - PHP Framework
- Angular - JavaScript Framework
- Vue - JavaScript Framework
- Jest - JavaScript Testing Framework