Question

In: Computer Science

HOW TO: 1. Write the SQL statement to show workers with names that have the letter...

HOW TO:

1. Write the SQL statement to show workers with names that have the letter ? before the last character.
2. Write the SQL statement to show all staff where the 2nd letter of their last names is ′?′
3. Write the SQL statement to show all staff where the 1stletter of their first names is ′?′ and 3rd letter ′ℎ'

DROP TABLE IF EXISTS staff;
CREATE TABLE staff (
staffNo VARCHAR(4) UNIQUE,
fName VARCHAR(16),
lName VARCHAR(16),
position VARCHAR(16),
sex VARCHAR(1),
dob DATETIME,
salary DOUBLE DEFAULT 0,
branchNo VARCHAR(4),
CONSTRAINT pk_staff PRIMARY KEY (staffNo)
);
INSERT INTO staff (staffNo,fName,lName,position,sex,DOB,salary,branchNo)
VALUES
('SL21','John','White','Manager','M','1945-10-01',30000,'B005'),
('SG37','Ann','Beech','Assistant','F','1960-11-10',12000,'B003'),
('SG14','David','Ford','Supervisor','M','1958-03-24',18000,'B003'),
('SA9','Mary','Howe','Assistant','F','1970-02-19',9000,'B007'),
('SGS','Susan','Brand','Manager','F','1940-06-03',24000,'B003'),
('SL41','Julie','Lee','Assistant','F','1965-06-13',9000,'B005'),
('SB0', NULL, 'LN0', 'Manager', 'M', '2000-01-01 00:00:00', 9999,
'B000'),
('SB1', 'FN1', NULL, 'Manager', 'M', NULL, 9999, 'B000'),
('SB2', 'FN2', 'LN2', NULL, NULL, NULL, 9999, 'B000'),
('SB3', 'FN3', 'LN3', NULL, NULL, NULL, 9999, NULL),
('SB4', 'FN4', NULL, 'Manager', NULL, NULL, 9999, NULL),
('SB5', 'FN5', NULL, 'Supervisor', NULL, NULL, NULL, 'B001'),
('SB6', 'FN6', NULL, 'Assistant', NULL, NULL, 9999, 'B002'),
('SB7', 'FN7', NULL, 'Manager', NULL, NULL, NULL, 'B003'),
('SB8', 'FN8', NULL, 'Manager', NULL, NULL, 9999, 'B005'),
('SB9', 'FN9', NULL, 'Assistant', NULL, NULL, NULL, NULL);

Solutions

Expert Solution

Dear Student ,

As per the requirement submitted above , kindly find the below solution.

This demonstration is using MySQL.

Question 1:

SQL Query :

SELECT * FROM staff where fName like '%i_'

Screen in MySQL:

*****************************

Question 2:

SQL Query :

SELECT * FROM staff where lName like '_e%';

Screen in MySQL:

*****************************

Question 3:

SQL Query :

SELECT * FROM staff where fName like 'e_h%';

Screen in MySQL:no first name in the table starts with e and third is h.

*****************************

NOTE : PLEASE FEEL FREE TO PROVIDE FEEDBACK ABOUT THE SOLUTION.


Related Solutions

PL/SQL Write a PL/SQL block, using a Case Statement that prints a student’s letter     grade...
PL/SQL Write a PL/SQL block, using a Case Statement that prints a student’s letter     grade based on the value stored in a variable called grade. Use the ACC      grading system described in the course syllabus to create the block and set     the initial value of grade as 95. Use only one print statement and no      logical operators in your code. Assume a grade can exceed 100, but it      can’t be negative. Grade Scale: Grade Scale:...
In sql: Write a query to produce a listing of unique vendor names who have at...
In sql: Write a query to produce a listing of unique vendor names who have at least one invoice with us. You are using a table view called COMPANY_INFORMATION that lists a vendor id, vendor name, term id, and term description. The second table you will reference is the invoice table that lists vendor id, invoice num, invoice number, and invoice total. Do not show duplicate results.
Write an SQL statement to show which customers boughtwhich items, and include any items that...
Write an SQL statement to show which customers bought which items, and include any items that have not been sold. Include LastName, FirstName, InvoiceNumber, InvoiceDate,ItemNumber, ItemDescription, ArtistLastName, and ArtistFirstName. Use a join using JOIN ON syntax, and sort the results by ArtistLastName and ArtistFirstName in ascending order (Hint: you have to use a RIGHT JOIN on the last step).
Write the following SQL queries and show the corresponding output of the DBMS: 1) Write an...
Write the following SQL queries and show the corresponding output of the DBMS: 1) Write an SQL statement to display all the information of all Nobel Laureate winners. 2) Write an SQL statement to display the string "Hello, World!". 3) Write an SQL query to display the result of the following expression: 2 * 14 +76. 4) Write an SQL statement to display the winner and category of all Laureate winners. 5) Write an SQL query to find the winner(s)...
Write SQL queries below for each of the following: List the names and cities of all...
Write SQL queries below for each of the following: List the names and cities of all customers List the different states the vendors come from (unique values only, no duplicates) Find the number of customers in California List product names and category descriptions for all products supplied by vendor Proformance List names of all employees who have sold to customer Rachel Patterson
In SQL we are working with functions 1. Write a SELECT statement that returns these columns...
In SQL we are working with functions 1. Write a SELECT statement that returns these columns from the Instructors table: a. The AnnualSalary column b. A column named MonthlySalary that is the result of dividing the AnnualSalary column by 12 c. A column named MonthlySalaryRounded that calculates the monthly salary and then uses the ROUND function to round the result to 2 decimal places 2. Write a SELECT statement that returns these columns from the Students table: a. The EnrollmentDate...
write a statement to guarantee that the initial will be a capital letter. write the code...
write a statement to guarantee that the initial will be a capital letter. write the code in jsGraph
1. Write a Formal Letter: SOLICITED LETTER: Write a cover letter for an advertised job, or...
1. Write a Formal Letter: SOLICITED LETTER: Write a cover letter for an advertised job, or a job about which you have specific knowledge (perhaps a new opening at your current place of employment).
1. Write a SQL statement which joins the rider_student table with the rider_major table and lists...
1. Write a SQL statement which joins the rider_student table with the rider_major table and lists the rider student name and the name of the major (major_name) and the description of the major for which they are currently assigned. (You may use the SQL 'join' subclause, or simply express the join as part of the 'where' clause by indicating that you only want records where the primary key of the child table, rider_major, equals the corresponding foreign key of the...
How to write a cover letter
How to write a cover letter
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT