Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

This is for my SQL class: Complete the Task 2 in answering the following questio

ID: 3723327 • Letter: T

Question

This is for my SQL class:

Complete the Task 2 in answering the following questions using Publishers database (Hint: The following questions contain concepts from Chapter 4 and Chapter 8).

1. SELECT a character string composed of the last two digits of the year of a title's pubdate, the pub_id, and the first ten characters of the title.

2. Display in one query output table the “id”, “name”, city, and state of both publishers and stores.

3. Write a SELECT statement that returns these columns from the Titles table:

The price column

A column that uses the CAST function to return the price column with 1 digit to the right of the decimal point

A column that uses the CONVERT function to return the price column as an integer

A column that uses the CAST function to return the price column as an integer

I attempted the first question but kept getting "Incorrect syntax near 'SUBSTRING'. Here's my code:

SELECT SUBSTRING(YEAR_OF_PUBDATE,LEN(YEAR_OF_PUBDATE)-2,LEN(YEAR_OF_PUBDATE))
PUB_ID SUBSTRING(TITLE,1,10)
FROM PUBLISHER;

Explanation / Answer

1. SELECT CONCAT(RIGHT(YEAR_OF_PUBDATE,2),PUB_ID,SUBSTRING(TITLE,1,10)) FROM PUBLISHER;

2. SELECT id,name,city,state FROM publishers UNION SELECT id,name,city,state FROM stores;

3.SELECT CAST(price AS decimal(10,1)),CONVERT(int,price), CAST(price AS int) FROM Titles

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote