Murach’s SQL for SQL Server – Exercise 8 – Guaranteed 100% score
1. Write a SELECT statement that returns four columns based on the InvoiceTotal
column of the Invoices table:
Use the CAST function to return the first column as data type decimal with 2
digits to the right of the decimal point.
Use CAST to return the second column as a varchar.
Use the CONVERT function to return the third column as the same data type as
the first column.
Use CONVERT to return the fourth column as a varchar, using style 1.
2. Write a SELECT statement that returns four columns based on the InvoiceDate
column of the Invoices table:
Use the CAST function to return the first column as data type varchar.
Use the CONVERT function to return the second and third columns as a varchar,
using style 1 and style 10, respectively.
Use the CAST function to return the fourth column as data type real.
3. Write a SELECT statement that returns two columns based on the Vendors table.
The first column, Contact, is the vendor contact name in this format: first name
followed by last initial (for example, “John S.”) The second column, Phone, is the
VendorPhone column without the area code. Only return rows for those vendors in
the 559 area code. Sort the result set by first name, then last name.
4. Write a SELECT statement that returns the InvoiceNumber and balance due for
every invoice with a non-zero balance and an InvoiceDueDate that’s less than 30
days from today.
5. Modify the search expression for InvoiceDueDate from the solution for exercise 4.
Rather than 30 days from today, return invoices due before the last day of the current
month.
6. Write a summary query WITH CUBE that returns LineItemSum (which is the sum of
InvoiceLineItemAmount) grouped by Account (an alias for AccountDescription) and
State (an alias for VendorState). Use the CASE and GROUPING function to
substitute the literal value “*ALL*” for the summary rows with null values.
7. (If you have access to the Examples database) Modify the third SELECT statement
shown in figure 8-11 of the text to return a middle name, if present. Add a third
column, Middle, which is null if no middle name is present.
* You can also use 2CO option if you want to purchase through Credit Cards/Paypal but make sure you put the correct billing information otherwise you wont be able to receive any download link.
* Your paypal has to be pre-loaded in order to complete the purchase or otherwise please discuss it with us at [email protected].
* As soon as the payment is received, download link of the solution will automatically be sent to the address used in selected payment method.
* Please check your junk mails as the download link email might go there and please be patient for the download link email. Sometimes, due to server congestion, you may receive download link with a delay.
* All the contents are compressed in one zip folder.
* In case if you get stuck at any point during the payment process, please immediately contact us at [email protected] and we will fix it with you.
* We try our best to reach back to you on immediate basis. However, please wait for atleast 8 hours for a response from our side. Afterall, we are humans.
* Comments/Feedbacks are truely welcomed and there might be some incentives for you for the next lab/quiz/assignment.
* In case of any query, please donot hesitate to contact us at [email protected].
* MOST IMPORTANT Please use the tutorials as a guide and they need NOT to be used for any submission. Just take help from the material.
******************************************** Good Luck ***************************************************