Question:
SQL Questions Help??????????????????????
James Smith
2010-11-17 06:17:47 UTC
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.
Four answers:
TheMadProfessor
2010-11-17 08:41:41 UTC
As previously stated, it would help if you listed something of the schema. But more importantly, have you made an attempt yourself or are you just looking for someone to do your homework for you?
?
2010-11-21 05:52:29 UTC
I'll help you out with #3. -But you should be trying this yourself. If you added some comments on what you've tried and are having trouble with I think more people would respond.



That said,



SELECT VendorContactFName + ', ' +

LEFT(VendorContactLName,1) + '.' AS 'Contact Name',

RIGHT(VendorPhone,8)AS 'Phone #'

FROM Vendors

WHERE LEFT(VendorPhone,5) = '(559)'

ORDER BY VendorContactFName,VendorContactLName
anonymous
2016-02-27 04:27:03 UTC
the thing in the bracket should be a column name of your table that you want to sum all the returned records for that column. The sum will always return something, even when the summation result is zero, it will return as zero instead of no record
?
2010-11-17 06:32:01 UTC
I would like to help you, but it would be easier if you can provide structure of tables.

for each table provide { column name and column type }


This content was originally posted on Y! Answers, a Q&A website that shut down in 2021.
Loading...