Bank account details - HackerEarth Solution (SQL Questions)
Bank account details - HackerEarth Solution (SQL Questions)
Problem Name - Bank account details
Problem Statement
A restaurant maintains information about its employees in a table called Employee.
Task
Your task is to write a query to determine the following values about a male employee who is a manager:
- ACCOUNT_NO
- FIRST_NAME
- LAST_NAME
Input format
Name | Type | Description |
---|---|---|
EMP_ID | Integer |
Represents a number in the inclusive range of [1, 1000] that uniquely identifies an employee ID Note: This is the primary key. |
FIRST_NAME | String | Represents the first name of an employee |
LAST_NAME | String | Represents the last name of an employee |
ROLE | Integer | Represents the role of an employee |
DOB | Date | Represents the date of birth of an employee |
GENDER | String | Represents the gender of an employee |
ACCOUNT_NO | Integer | Represents the account number of an employee |
Output format
The output of the query must contain FIRST_NAME, LAST_NAME, and ACCOUNT_NO of a male employee who is a manager.
Note: The last four digits of ACCOUNT_NO must be xxxx.
Instructions
- The query written in MySQL is case sensitive.
- Only select queries are allowed.
Example
Sample input
EMP_ID | FIRST_NAME | LAST_NAME | ROLE | DOB | GENDER | ACCOUNT_NO |
---|---|---|---|---|---|---|
1 | JAMES | SMITH | ACCOUNTANT | 1971-01-01 | M | 370762569730 |
2 | MICHAEL | SMITH | CHEF | 1994-12-30 | F | 832347096055 |
3 | MARIA | GARCIA | MANAGER | 1990-08-12 | F | 326317297866 |
4 | MARY | SMITH | WAITER | 1998-11-09 | F | 444196665241 |
5 | MARIA | MARTINEZ | CHEF | 1982-12-16 | F | 557792895268 |
6 | NANCY | JONES | ACCOUNTANT | 1993-05-19 | F | 764267213085 |
7 | JAMES | JOHNSON | MANAGER | 1991-06-21 | M | 209704581959 |
8 | HENRY | TAYLOR | WAITER | 1990-07-24 | M | 892376162850 |
Sample output
JAMES JOHNSON 20970458xxxx
Sample Explanation
The output prints the name of an employee whose role is Manager and gender is Male along with his account number whose last 4 digits are printed as xxxx.
Bank account details - HackerEarth Solution (SQL Questions)
SQL Query -
Select FIRST_NAME, LAST_NAME,ConCat(SubString(ACCOUNT_NO,1,8),'xxxx')from Employee where role='Manager' and GENDER='M';
Post a Comment