SQL,Oracle and Knowledge with Section Weightage
18-Feb-2020 10:37
18-Feb-2020 10:41
4 Mins
| Section Name | Pass Percentage | Candidate Score | Status |
|---|---|---|---|
| Knowledge | 50% | 0% | Fail |
| SQL Server | 50% | 20% | Fail |
| Oracle | N/A | 0% | N/A |
9 / 14
5 / 14
| Section Name | Total Questions | Answered | Not Answered | Correct Marks | Partial Marks | Penalty Marks | Score |
|---|---|---|---|---|---|---|---|
| Knowledge | 5 | 5 | 0 | 0.00 | 0.00 | 0.00 | 0.00 |
| SQL Server | 5 | 3 | 2 | 10.00 | 0.00 | 0.00 | 10.00 |
| Oracle | 4 | 1 | 3 | 0.00 | 0.00 | 0.00 | 0.00 |
10 seconds InCorrect
All aggregate functions ignore NULLs except for?
2 seconds InCorrect
When are the values in an SQL view changeable through the view itself?
I: always
II: not always, but the rules to determine modification status are simple
III: not always, and the rules to determine modification status are complicated
IV: not always, and the rules to determine modification status are DBMS-dependent
2 seconds InCorrect
Which statement is true regarding synonyms?
2 seconds InCorrect
An index helps speed up SELECT queries and WHERE clauses, but it slows down data input, with UPDATE and INSERT statements. State True or False.
11 seconds InCorrect
What is the main use of Rollback segment?
I: used to rollback the transaction
II: They can be used to recover the selected tables to a consistent state in case of failures.
III: They ensure that the transactions leave the uncommitted changes unnoticed.
I only
II only
III only
Both I and II
I, II and III
Both I and II
In this case study, the Human Resource Management System given below to track and maintain complete employee, department, and pay history details.
As an SQL developer, you are expected to write queries to analyse data, based on the given requirements and business conditions.
Following are the list of tables are already defined
1. Address
2. CountryRegion
3. ContactType
4. Contact
5. AddressType
6. StateProvince
7. Shift
8. Department
9. Employee
10. EmployeePayHistory
11. EmployeeDepartmentHistory
12. EmployeeAddress
13. Employee_Test_Audit
Department
| Column | DataTypes | Nullability | Description |
| DepartmentId | small int | Not Null | Primary key for Department rows. |
| Name | nvarchar | Not Null | Name of the department. |
| GroupName | nvarchar(50) | Not Null | Name of the group to which the department belongs. |
| ModifiedDate | datetime | Not Null | Date and time the row was last updated. |
Employee
| Column | Data type | Nullability | Description |
| EmployeeID | int | Not null | Primary key for employee rows. |
| NationalIDNumber | nvarchar(15) | Not null | Unique national identification number such as a social security number. |
| ContactID | int | Not null | Identifies the employee in the Contact table. Foreign key to Contact.ContactID. |
| LoginID | nvarchar(256) | Not null | Network logon. |
| ManagerID | int | Null | Manager to whom the employee is assigned. Foreign key to Employee.EmployeeID. |
| Title | nvarchar(50) | Not null | Work title such as Buyer or Sales Representative. |
| BirthDate | datetime | Not null | Date of birth. |
| MaritalStatus | nchar(1) | Not null |
M = Married S = Single |
| Gender | nchar(1) | Not null |
M = Male F = Female |
| HireDate | datetime | Not null | Date on which the employee was hired. |
| SalariedFlag | bit | Not null |
Job classification. 0 = Hourly, not exempt from collective bargaining. 1 = Salaried, exempt from collective bargaining. |
| VacationHours | smallint | Not null | Number of available vacation hours. |
| SickLeaveHours | smallint | Not null | Number of available sick leave hours. |
| CurrentFlag | bit | Not null |
0 = Inactive 1 = Active |
| rowguid | uniqueidentifier ROWGUIDCOL | Not null | ROWGUIDCOL number that uniquely identifies the row. Used to support a merge replication sample. |
| ModifiedDate | datetime | Not null | Date and time the row was last updated. |
Employee Address
| Column | Data type | Nullability | Description |
| EmployeeID | int | Not null | Employee identification number. Foreign key to Employee.EmployeeID |
| AddressID | int | Not null | Employee address identification number. Foreign key to Address.AddressID. |
| rowguid | uniqueidentifier ROWGUIDCOL | Not null | ROWGUIDCOL number that uniquely identifies the row. Used to support a merge replication sample. |
| ModifiedDate | datetime | Not null | Date and time the row was last updated. |
EmployeeDepartmentHistory
| Column | Data type | Nullability | Description |
| EmployeeID | int | Not null | Employee identification number. Foreign key to Employee.EmployeeID. |
| DepartmentID | smallint | Not null | Department in which the employee works or worked. Foreign key to Department.DepartmentID |
| ShiftID | tinyint | Not null | Work shift, such as day, evening, or night, to which the employee is assigned. Foreign key to Shift.ShiftID. |
| EndDate | datetime | Null |
Date the employee left the department. NULL = Current department |
| StartDate | datetime | Not null | Date the employee started work in the department. |
| ModifiedDate | datetime | Not null | Date and time the row was last updated. |
EmployeePayHistory
| Column | Data type | Nullability | Description |
| EmployeeID | int | Not null | Employee identification number. Foreign key to Employee.EmployeeID. |
| RateChangeDate | datetime | Not null | Date the change in pay is effective. |
| Rate | money | Not null | Hourly rate of pay. |
| PayFrequency | tinyint | Not null |
1 = Salary received monthly 2 = Salary received biweekly |
| ModifiedDate | datetime | Not null | Date and time the row was last updated. |
Note: PRIMARY KEY CLUSTERED – EmployeeID, RateChangeDate
Shift
| Column | Data type | Nullability | Description |
| ShiftID | smallint | Not null | Primary key. |
| Name | nvarchar(50) | Not null | Shift description. |
| StartTime | datetime | Not null | Shift start time. |
| EndTime | datetime | Not null | Shift end time. |
| ModifiedDate | datetime | Not null | Date and time the row was last updated. |
Address
| Column | Data type | Nullability | Description |
| AddressID | Not null | Primary key for address rows. | |
| AddressLine1 | nvarchar(60) | Not null | First street-address line. |
| AddressLine2 | nvarchar(60) | Null | Second street address line. |
| City | nvarchar(30) | Not null | Name of the city. |
| StateProvinceID | int | Not null | Unique identification number for the state or province. Foreign key to StateProvince.StateProvinceID. |
| PostalCode | nvarchar(15) | Not null | Postal code for the street address. |
| rowguid | uniqueidentifier ROWGUIDCOL | Not null | ROWGUIDCOL number uniquely identifying the row. Used to support a merge replication sample. |
| ModifiedDate | datetime | Not null | Date and time the row was last updated. |
AddressType
| Column | Data type | Nullability | Description |
| AddressTypeID | int | Not null | Primary key for AddressType rows. |
| Name | nvarchar(50) | Not null | Address type description. For example, billing, home, or shipping. |
| rowguid | uniqueidentifier ROWGUIDCOL | Not null | ROWGUIDCOL number uniquely identifying the row. Used to support a merge replication sample. |
| ModifiedDate | datetime | Not null | Date and time the row was last updated. |
Contact
| Column | Data type | Nullability | Description |
| ContactID | int | Not null | Primary key for Contact rows. |
| NameStyle | bit | Not null |
Indicates the column in which the family name is stored. 0 = Family name is stored in LastName and the first name is stored in FirstName. 1 = .Family name is stored in FirstName and the first name is stored in LastName. |
| Title | nvarchar(8) | Null | A courtesy title. For example, Mr. or Ms. |
| FirstName | nvarchar(50) | Not null | First name of the person. |
| MiddleName | nvarchar(50) | Not null | First name of the person. |
| LastName | nvarchar(50) | Not null | Last name of the person. |
| Suffix | nvarchar(10) | Null | Surname suffix. For example, Sr. or Jr. |
| EmailAddress | nvarchar(50) | Null | E-mail address for the person. |
| EmailPromotion | int | Not null |
0 = Contact does not wish to receive e-mail promotions. 1 = Contact does wish to receive e-mail promotions. |
| Phone | nvarchar(25) | Null | Phone number associated with the person. |
| PasswordHash | varchar(128) | Not null | Password for the e-mail account. |
| PasswordSalt | varchar(10) | Not null | Random value concatenated with the password string before the password is hashed. |
| AdditionalContactInfo | xml | Null |
Additional contact information about the person, such as additional phone numbers and addresses or special instructions and notes. Data is stored in XML format. For more information, see About the Contact.AdditionalContactInfo xml Column |
| rowguid | uniqueidentifier ROWGUIDCOL | Not null | ROWGUIDCOL number uniquely identifying the row. Used to support a merge replication sample. |
| ModifiedDate | datetime | Not null | Date and time the row was last updated. |
ContactType
| Column | Data type | Nullability | Description |
| ContactTypeID | int | Not null | Primary key for ContactType records. |
| Name | nvarchar(50) | Not null | Contact type description. |
| ModifiedDate | datetime | Not null | Date and time the row was last updated. |
CountryRegion
| Column | Data type | Nullability | Description |
| CountryRegionCode | nvarchar(3) | Not null | Primary key.Standard code identifying countries and regions. |
| Name | nvarchar(50) | Not null | Country or region name. |
| ModifiedDate | datetime | Not null | Date and time the row was last updated. |
StateProvince
| Column | Data type | Nullability | Description |
| StateProvinceID | int | Not null | Primary key. |
| StateProvinceCode | nchar(3) | Not null | State or province code. |
| CountryRegionCode | nvarchar(3) | Not null | Country or region code. Foreign key to CountryRegion.CountryRegionCode. |
| IsOnlyStateProvinceFlag | bit | Not null |
0 = StateProvinceCode exists. 1 = StateProvinceCode unavailable, use CountryRegionCode. |
| Name | nvarchar(50) | Not null | State or province description. |
| TerritoryID | int | Not null | ID of the Adventure Works sales territory in which the state or province is located. Foreign key to SalesTerritory.SalesTerritoryID. |
| rowguid | uniqueidentifier | Not null | ROWGUIDCOL number uniquely identifying the row. Used to support a merge replication sample. |
| ModifiedDate | datetime | Not null | Date and time the row was last updated. |
39 seconds InCorrect
Write a query to select EmployeeName, Gender, EmployeeID, ManagerID, Title
Design Rules :
1. For EmployeeName use ‘FirstName’ and 'LastName' seperated by a single space delimiter. Order should be ‘FirstName’
followed by a space, then the ‘LastName’. (Ex: FirstName LastName)
2. Return only employees whose FirstName starts with letter 'S'
3. Order the output by FirstName
Tables: Employee, Contact
Guidelines:
Sample Output:
| EMPLOYEENAME | GENDER | EMPLOYEEID | MANAGERID | TITLE |
| Sandra Altamirano | M | 9 | 4 | Production Technician -WC45 |
| Selena Alvarado | M | 10 | 4 | Production Technician -WC60 |
SELECT firstname + ' ' + lastname AS 'EmployeeName',
E.gender, employeeid, managerid, E.title
FROM employee AS E
JOIN contact AS C
ON C.contactid = E.contactid
WHERE firstname LIKE 'S%'
ORDER BY firstnameSELECT
c.LastName , c.FirstName , emain.EmployeeID , d.name as Department, eph.Rate
FROM Department d
INNER JOIN EmployeeDepartmentHistory edhmain
ON d.DepartmentID = edhmain.DepartmentID
INNER JOIN EmployeePayHistory eph
ON eph.EmployeeID = edhmain.EmployeeID
INNER JOIN Employee emain
ON edhmain.EmployeeID = emain.EmployeeID
INNER JOIN Contact c
ON emain.ContactID = c.ContactID
WHERE c.FirstName like 'P%';| Test Case Name | Test Case Description | Primary TestCase | Secondary TestCase |
|---|---|---|---|
| Validate_Employee_Details | To validate the employee details |
50 seconds InCorrect
The EmployeePayHistory will have the rate history for each year. Write a query to fetch the number of Rate change happened for the years 1996, 1997 and 1998
Design Rules :
1. Display Year using column RateChangeDate in YYYY format for the years 1996, 1997 and 1998
2. The output will have Year, No of Rates Changed
3. Order the output by Year
Tables: EmployeePayHistory
Guidelines:
Sample Output:
| YEAR | NO OF RATES CHANGED |
| 1996 | 1 |
| 1997 | 4 |
| 1997 | 4 |
SELECT Year(RateChangeDate) AS [Year], COUNT([Rate]) AS [No of Rates Changed]
FROM [EmployeePayHistory]
WHERE Year(RateChangeDate) in ('1996','1997','1998')
GROUP BY Year(RateChangeDate)
order by Year(RateChangeDate)SELECT Year(RateChangeDate) AS [Year],
COUNT([Rate]) AS [No of Rates Changed],
COUNT(DISTINCT Rate) AS [DistinctRates]
FROM [EmployeePayHistory]
WHERE Year(RateChangeDate) in ('1996','1997','1998')
GROUP BY Year(RateChangeDate);| Test Case Name | Test Case Description | Primary TestCase | Secondary TestCase |
|---|---|---|---|
| Validate_Retrieval_of_Rate_Details | To Validate_Retrieval_of_Rate_Details |
Not Answered
Write a stored procedure to select the details of employees like LastName, FirstName, City, StateProvinceCode
Design Rules :
1. Use Joins
2. Do not submit your query with other keywords like alter procedure or execute procedure. Only the create procedure text should be submitted
PROCEDURE NAME: GetEmployeeDetails
INPUT PARAMETERS: @StateProvinceCode
Tables: Contact, Employee, EmployeeAddress, Address, StateProvince
Guidelines:
Sample Output:
| LASTNAME | FIRSTNAME | CITY | STATEPROVINCECODE |
| Adina | Ronald | Camrose | AB |
| Issac | Michael | Brooks | AB |
| Ault | John | Cold Lake | AB |
45 seconds Correct
Write a query to return Employeeid,Managerid,Title,Gender using Pagination concept
Design Rules :
1. Ignore the first 5 rows and select the next 3 rows using pagination concept
2. Order the resultset by EmployeeID
Tables: Employee
Guidelines:
Sample Output:
| EMPLOYEEID | MANAGERID | TITLE | GENDER |
| 6 | 1 | Master Scheduler | M |
| 7 | 4 | Production Technician - WC30 | F |
| 8 | 2 | Accounts Receivable Specialist | M |
select Employeeid,managerid,title,gender from
Employee
order by employeeid
offset 5 rows
fetch next 3 rows onlyselect Employeeid,managerid,title,gender from
Employee
order by employeeid
offset 5 rows
fetch next 3 rows only;| Test Case Name | Test Case Description | Primary TestCase | Secondary TestCase |
|---|---|---|---|
| Validate_Pagination_Concept | Validate_Pagination_Concept |
3 seconds Not Answered
Rate incrementation for each ModifiedYear needs to be captured
Write a query to select ModifiedYear, Rate and RateRanking (Highest rate to be ranked 1 and so on)
Design Rules :
1. Get Modified Year from the column ModifiedDate and use alias name 'ModifiedYear'
2. For RateRanking use ranking statements to Rank the Rates (Highest Rate to be ranked 1 and so on) for each Modified Year. Use alias name 'RateRanking'
3. Modified Year greater than 2000 only
4. Order the output by ModifiedDate
5. Refer the sample output for your reference
Tables:
EmployeePayHistory
Guidelines:
Sample Output:
| MODIFIEDYEAR | RATE | RATERANKING |
| 2002 | 40.8462 | 1 |
| 2002 | 29.8462 | 2 |
| 2002 | 22.00 | 3 |
| 2004 | 13.4615 | 1 |
| 2004 | 12.699 | 2 |
| 2004 | 4.00 | 3 |
The order management system is a software system used in a number of industries for order entry and processing.
The below order management system portal receives and processes orders from various mechanical related industries which deals with spare parts for automotive industry.
Various reports and data needs to be mined based on the orders placed. As an oracle solution consultant, you have been provided with requirements by the company directors.
The database structure is below.
| Table Name | Description |
| T_STOCK_DETAILS | Contains list of stock items, price and current availability |
| T_CUSTOMER | Contains personal details of the customer |
| T_ORDER_PLACEMENT | Contains details of order placed by a customer such as order date, shipment date and address etc. |
| T_ORDER_DETAILS |
Contains item level details for each order |
| T_LOG_ERR | Log table created for logging during the execution of the procedures |
Table Description Below:
T_CUSTOMER Table which stores the Customer Information
|
CUST_ID |
Id to identify the Customer |
|
CUST_NAME |
Name of the Customer |
|
CUST_ADDRESS |
Address of the Customer |
|
CUST_CITY |
City of the Customer |
|
CUST_STATE |
State Code of the Customer |
|
CUST_ZIP_CODE |
Zip Code of the Customer |
|
CUST_MAIL |
Email-ID for Customer |
|
CUST_PHONE |
Contact Number of the Customer |
T_ORDER_PLACEMENT Table which stores the Customer order
|
ORDER_ID |
Id to identify order of the Customer |
|
CUST_ID |
Id to identify the Customer ( References T_CUSTOMER) |
|
ORDER_DATE |
Date of the order placement |
|
SHIPMENT_DATE |
Delivery date of the Order |
|
SHIP_ADDRESS |
Delivery Address Line of the Order |
|
SHIP_CITY |
Delivery City of the Order |
|
SHIP_STATE |
Delivery State of the Order |
|
SHIP_ZIP_CODE |
Delivery Zip code of the Order |
|
SHIPMENT_STATUS |
Shipment Status of the Order |
T_ORDER_DETAILS Table which stores the Customer Order Details
|
ITEM_ID |
Sequential Id to each Order Item |
|
|
ORDER_ID |
Id to identify order ( References T_ORDER_PLACEMENT) |
|
|
STOCK_ID |
Id to identify the Stock item (References T_STOCK_DETAILS) |
|
|
QUANTITY |
Quantity of the order item |
|
|
DISCOUNT_PERCENTAGE |
|
|
|
TOTAL_COST |
Cost of the item after detecting the Discount |
T_STOCK_DETAILS Table which stores the Stock item Details
|
STOCK_ID |
Id to identify Stock item of the order |
|
STOCK_NAME |
Name of the stock item |
|
PRICE |
Cost of the each item |
|
STOCK_BALANCE_QTY |
Remanining stock balance quantity |
T_LOG_ERR Table which stores Error Details
|
MESSAGE |
Error message along with Error code during Exceptions |
|
LOG_DATE |
Sysdate |
38 seconds InCorrect
Write a query that returns the orders which was shipped with minimum duration from the date of the order placed.
Design rules:
Guidelines:
Sample Output:
| ORDER_ID | MINIMUM_DURATION_IN_DAYS |
| 12345 | 1 |
SELECT order_id,(shipment_date - order_date)AS MINIMUM_DURATION_IN_DAYS
FROM t_order_placement
WHERE (shipment_date - order_date)= ( SELECT MIN(shipment_date-order_date) FROM t_order_placement)
ORDER BY ORDER_ID;select * from T_order_details;| Test Case Name | Test Case Description | Primary TestCase | Secondary TestCase |
|---|---|---|---|
| Testing minimum shipped order | Testing minimum shipped order |
Not Answered
Write a query that updates the discount percentage based on the below constraints :
Design Rules:
Guidelines:
Not Answered
Write a query that retrives the customer details along with the order and stock details. (Retrieve only the columns which is mentioned in the design rules)
Use Joins to achieve this.
Design rules:
Guidelines:
Sample Output:
| CUST_ID | ORDER_DATE | ORDER_ID | STOCK_ID |
| 101 | 12-FEB-12 | 12345 | 1002 |
| 101 | 05-NOV-12 | 98765 | 1005 |
| 102 | 14-FEB-12 | 56789 | 1006 |
Not Answered
Write a Pl / Sql function that takes customer id as input and retrieves the shipment status of the customer.
Input parameter :Customer id
Output parameter : SHIPMENT_STATUS
Exception scenario :
If there is no customer with the given input id, then raise application error expcetion with the error message as 'ERROR'
Guidelines:
Report generated time : 18-02-2020 04:04 PM
Powered by