Question

Hi i need to write an SQL Query to list the given for these questions below...

Hi i need to write an SQL Query to list the given for these questions below

Example: SELECT emp_lname -- but it doent seem to work

--1. Give a Listing of all the employees having their first name,

last name and full name, order the report by the employee's last name

--2. Give a listing of all employees that have a last name that

begins with the letters between A-K

--3. Give a Listing of all the employees having their first name,

last name, full name and full telephone number where the area code is 412

--4. Give a Listing of all the addresses of employees not residing

in Florida

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

1. Give a Listing of all the employees having their first name, last name and full name, order the report by the employee's last name

Ans: select f_name, l_name, (f_name || ' ' || l_name) as full_name from emp ORDER BY l_name;

Note: We have considered first name column as f_name, last name column as l_name. We have derived a new column in our output with name; full_name by concatenating first name and last name.

2. Give a listing of all employees that have a last name that begins with the letters between A-K

Ans: select * from emp where l_name like 'A%' OR l_name like 'B%'  OR l_name like 'C%' OR l_name like 'D%' OR l_name like 'E%' OR l_name like 'F%' OR l_name like 'G%' OR l_name like 'H%' OR l_name like 'I%' OR l_name like 'J%' OR l_name like 'K%';

Note: In the above query, all employee details will be displayed whose last name begins with letters between A-K.

3. Give a Listing of all the employees having their first name,last name, full name and full telephone number where the area code is 412

Ans: select f_name, l_name, (f_name || ' ' || l_name) as full_name, t_no from emp where area_code=412;

4. Give a Listing of all the addresses of employees not residing in Florida

Ans: select (fname || ' ' || l_name) as full_name, address from emp where city not in ('Florida');

Please Note:- we have referred employee table to emp, first name to f_name, last name to l_name, telephone number to t_no, area code to area_code and residing city to city. Also, we have derived a new column full_name by concatenating f_name and l_name at run time.

Add a comment
Know the answer?
Add Answer to:
Hi i need to write an SQL Query to list the given for these questions below...
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
  • Write an sql query to list the customers last name, seating cost, seating tip and service...

    Write an sql query to list the customers last name, seating cost, seating tip and service date for all customers with last name Smith or jones or brown. SAMPLE DATA BASE (Key fields are underlined.) Employee EMP_ID EMP_FNAME EMP_LNAME EMP_STREET EMP_CITY EMP_STATE EMP_ZIP EMP_START_DATE Table TABLE D AREA ID TABLE SEATS Area AREA_ID AREA NAME AREA SUPERVISOR EMPLOYEE_ID Customer CUST ID CUST_LAST_NAME CUST_NUMBER_OF_GUESTS Assignment EMP ID TABLE ID Seating CUST_ID TABLE_ID SEATING COST SEATING DATE SEATING TIP

  • j. Create a SQL query based on tblTransaction and tblEmployees that will display all the fields...

    j. Create a SQL query based on tblTransaction and tblEmployees that will display all the fields from tblTransaction and the FirstName and LastName fields from tblEmployees. Use a join to include all employees, regardless if they have sold any products. Sort in ascending order by the employee’s first name and last name. Save your query as qryEmpTransaction_initialLastname, and then close the query. Feilds from tbl Transaction are TransactionID, CustomerID, EMployeeID, TransactionDate, MethodOfPayment Feilds from tbl Employees are EmployeeID, FirstName, LastName,...

  • I need to write a SQL query that displays the first name and last name of...

    I need to write a SQL query that displays the first name and last name of each author along with the number of books he or she has written. Capitalize the first and last names. AUTHOR table: AUTHORID, LNAME, FNAME BOOKAUTHOR table: ISBN, AUTHORID BOOKS table: ISBN, TITLE, PUBDATE, PUBID, COST, RETAIL, DISCOUNT, CATEGORY

  • 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 a query in SQL to list the following information of the artists in movie industry....

    Write a query in SQL to list the following information of the artists in movie industry. Limit this information to only 5 artists. Sort the information by age descending order.          Full name : first name and last name separated by space          Age: Current age          Address: State that he resides          Contact number: Phone number This is from an artist table, where first_name, last_name, contact_no, address, birth_date are the fields in the table. Birth date in the table...

  • I have no experience with SQL and I need to write commands to query the following:...

    I have no experience with SQL and I need to write commands to query the following: List all patients with the last name of “Johnson”. List all patients who are female. List all patient last names and the medical record number of each. I've watched Khanacademy videos and tried some other online tutorials but I just cannot find the information or help I need to finish this assignment. I'm in an HIM program, but that is not an option on...

  • can someone solve these quick please and thank you! sql chapter 4 Query #1: List the...

    can someone solve these quick please and thank you! sql chapter 4 Query #1: List the company name, contact name, contact title and the phone number for customers who HAVE NOT put in an order. Use an outer join. Query #2: Create a listing displaying the employee first name, last name and the full name (First name space Last Name) of the person they report to (Supervisor). This is a self-join. If an employee does not report to anyone then...

  • Write SQL code please. Tables are attached with their appropriate fields for reference. The Marketing Department...

    Write SQL code please. Tables are attached with their appropriate fields for reference. The Marketing Department requires a vendor listing that shows the following fields: 1. - Vendor Name Vendor Contact First Name - Vendor Contact Last Name - Vendor City - Vendor State - Vendor Zip Code Note: Sort by vendor state The Finance Department requires a report that shows payment totals greater than $50.00. List the following fields 2. - Vendorid - Payment Total - Payment Date The...

  • 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...

  • Can you please write the MySQL Query sentences for the following items below? For example: SELECT...

    Can you please write the MySQL Query sentences for the following items below? For example: SELECT * FROM employees; Generate a list of salespeople sorted descending by hire date. Show the ID, first name, last name, hire date, and salary for each salesperson. Generate a list of customers whose last name begins with the letter “M.” Show the first and last names of these customers. Sort the list of customers descending by last name. C. Generate a list of customers...

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