Question

Write an SQL statement that will display the Employee ID, First name (only last 2 letters),...

Write an SQL statement that will display the Employee ID, First name (only last 2 letters), phone number (replace . by /) of all employees whose job Id has a word ‘REP’.

0 0
Add a comment Improve this question Transcribed image text
Answer #1

Explanation::

  • An table named Employee is created and select query is run on the same

CREATE TABLE QUERY::

CREATE TABLE EMPLOYEE (
employeeID INT NOT NULL,
firstName VARCHAR(100),
lastname VARCHAR(100),
phoneNumber VARCHAR(100),
jobID varchar(100),
PRIMARY KEY (employeeID)
);

-------------------------------------------------------------------------------------------------------

INSERT QUERY FOR SOME DATA IN TABLE::


INSERT INTO EMPLOYEE(employeeID,firstName,lastname,phoneNumber,jobID) values(123,'Steve','Berry','123.456.789','REPORTER');
INSERT INTO EMPLOYEE(employeeID,firstName,lastname,phoneNumber,jobID) values(124,'Amanda','Pelkey','127.488.289','CREW');
INSERT INTO EMPLOYEE(employeeID,firstName,lastname,phoneNumber,jobID) values(125,'Harry','Potter','127.488.289','Presenter');
INSERT INTO EMPLOYEE(employeeID,firstName,lastname,phoneNumber,jobID) values(126,'Hermione','Granger','127.488.289','Representative');
INSERT INTO EMPLOYEE(employeeID,firstName,lastname,phoneNumber,jobID) values(127,'Ronald','Weasley','127.488.289','Prep Team');
INSERT INTO EMPLOYEE(employeeID,firstName,lastname,phoneNumber,jobID) values(128,'Tom','Riddle','127.488.289','Fire Team');
INSERT INTO EMPLOYEE(employeeID,firstName,lastname,phoneNumber,jobID) values(129,'Sirius','Black','127.488.289','Reporter');
INSERT INTO EMPLOYEE(employeeID,firstName,lastname,phoneNumber,jobID) values(130,'Nevil','Longbottom','127.488.289','Helper');
INSERT INTO EMPLOYEE(employeeID,firstName,lastname,phoneNumber,jobID) values(131,'Parvati','Patil','127.488.289','Press');

QUERY::

SELECT * FROM EMPLOYEE GIVES::

ANSWER QUERY::

SELECT employeeID,RIGHT(firstname,2),REPLACE(phoneNumber,'.','/') FROM EMPLOYEE WHERE jobID LIKE '%REP%';

OUTPUT::

Please provide the feedback!!

Thank You!!

Add a comment
Know the answer?
Add Answer to:
Write an SQL statement that will display the Employee ID, First name (only last 2 letters),...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • SQL query: Write an SQL query that will output the last name, employee id, hire date and department from the employee table. Pick only those employees whose department ID is specified in the employee...

    SQL query: Write an SQL query that will output the last name, employee id, hire date and department from the employee table. Pick only those employees whose department ID is specified in the employee table. If the employee id is 777, name is ABC and hire date is 01-JAN-2016, the output should look as follows - 'Stephen (Employee ID - 777) was hired on the 1st of January, 2016 – Department: 90'. Note - The date should not have preceding...

  • Please refer to the following business scenarios: (i) Using SELECT statements of SQL, find the employee...

    Please refer to the following business scenarios: (i) Using SELECT statements of SQL, find the employee id, first name, last name, job title and email of all employees working in Asia (i.e. all countries coming from the region     ‘Asia’). This query must be implemented as a nested query! (ii) Using SELECT statements of SQL, find the employee id, first name, last name, job title and supervisor id of employees who had worked for more than 3 years and completed...

  • Use the HR database for all the questions in this lab. For each item in this lab, paste the SQL y...

    Use the HR database for all the questions in this lab. For each item in this lab, paste the SQL you used to complete the task and the number of rows retrieved. Ensure you follow the coding standards listed in the ETSU SQL standards guide found on D2L. Save this document as a PDF and name it your_name_lab7.pdf Display the employees’ first name, last name and phone number of employees with salaries greater than 10,000 dollars. SELECT first_name, last_name, phone_number,...

  • Write just one SQL statement per question 1. Display Publisher ID, Publisher Name and Total Number...

    Write just one SQL statement per question 1. Display Publisher ID, Publisher Name and Total Number of Books published by each publisher. 2. List Publisher ID, Publisher Name, Title and price of the highest priced book. 3. List Order ID, Customer ID, Order Date, and Number of Items in each order. Order the data by Customer ID in ascending (A – Z) order. 4. Display Title, Category and Profit for each book in the children and computer category. 5. Display...

  • I need this written in SQL Employee EMP ID EMP FNAME EMP LNAME EMP STREET EMP...

    I need this written in SQL Employee EMP ID EMP FNAME EMP LNAME EMP STREET EMP CITY EMP STATE EMP ZIP EMP START DATE Table TABLE ID AREA IDTABLE SEATS Area AREA ID AREA NAME AREA SUPERVISOR EMPLOYEE ID Customer CUST ID CUST LAST NAME CUST NUMBER OF GUESTS Assignment EMPID TABLE ID Seating CUST IDTABLE ID SEATING COST SEATING DATE SEATING TIP Question 29 (10 points) Write an SQL query to list the employee ID and first and last...

  • Given the following table structure, write the SQL code to display all the first and last...

    Given the following table structure, write the SQL code to display all the first and last names of the individuals that have a last name that begins with the letter 'M! CREATE TABLE Persons Personi int LastName varchar(80). FirstName varchar(80). Address varchar(125). State char(2) Given the following table structure, write the SQL code to display all the first and last names of the individuals that have a last name that does not contain the letter 'S: CREATE TABLE Persons PersonlDint,...

  • Problem 33, chapter 7 from Database Systems 13th edition by Coronel Write a query to display...

    Problem 33, chapter 7 from Database Systems 13th edition by Coronel Write a query to display the employee number, last name, email address, title, and department name of each employee whose job title ends in the word “ASSOCIATE.” Sort the output by department name and employee title Problem 36, chapter 7 from Database Systems 13th edition by Coronel Write a query to display the number of products within each base and type combination, sorted by base and then by type...

  • (PL/SQL Programming) Consider the table EMPLOYEE with attributes ID, Name, and Hours, and the table PAYINFO...

    (PL/SQL Programming) Consider the table EMPLOYEE with attributes ID, Name, and Hours, and the table PAYINFO with attributes Regular, Overtime, and HourLimit, defined and populated by the following script: DROP TABLE EMPLOYEE CASCADE CONSTRAINTS; CREATE TABLE EMPLOYEE (        ID            CHAR(5),        Name          VARCHAR2(16),        Hours         NUMBER(2),        CONSTRAINT PK_EMPLOYEE               PRIMARY KEY (ID) ); INSERT INTO EMPLOYEE VALUES ('22144', 'Anderson', 30); INSERT INTO EMPLOYEE VALUES ('31902', 'Bruford', 45); INSERT INTO EMPLOYEE VALUES ('42771', 'Wakeman', 20); INSERT INTO EMPLOYEE VALUES...

  • Write PL/SQL or T-SQL procedures to accomplish the following tasks:a. Obtain the first name and last...

    Write PL/SQL or T-SQL procedures to accomplish the following tasks:a. Obtain the first name and last name of the owner whose number currently is storedin I_OWNER_NUM. Place these values in the variables I_FIRST_NAME andI_LAST_NAME. Output the contents of I_OWNER_NUM, I_FIRST_NAME, andI_LAST_NAME.

  • Write SQL authorization statements on the employee table as per the following requirements: Employee (id, name,...

    Write SQL authorization statements on the employee table as per the following requirements: Employee (id, name, job_name, dept_name, salary) - You have three managers with manager1, manager2 and manager3 user ids. All of them are members of the role manager. - All managers have the same privileges: select, insert, update, delete. - No managers can transfer his privileges on the employee table.

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT