Question

Hi this is for SQL Use the AP database Vendor name from the vendor table Vendor...

Hi this is for SQL

Use the AP database

Vendor name from the vendor table

Vendor Contact First Name and Vendor Contact Last Name from the vendor table but I need them concatenated together with a space between the names

Invoice Date from the invoice table

Only the day of from the Invoice Date

Invoice Number from the invoice table

The third and fourth characters from the Invoice Number

Line Item Amount from the invoice line items table

Calculate the commission which is the Line Item Amount * 15% and make it ONLY two decimals

The FROM is the Vendors table do JOINS on the others

The WHERE is where the Line Item Amount is greater than $2000 and the Invoice Date is between July 1, 2014 and July 31st, 2014 and I only want the ones that have either a 9 or a 2 in the Invoice Number

Sort by Invoice Date

My answer like this:

elect vendor_name as vendor, concat(first_name, ' ', last_name) as Contact, DAY(invoice_date) as ofday, invoice_date,
SUBSTRING(invoice_number, 3,2) as thirdFourth, line_item_amount,round(line_item_amount*.15, 2) as Commission
from vendors v
JOIN vendor_contacts vc
ON v.vendor_id = vc.vendor_id
JOIN INVOICES INV
ON V.VENDOR_ID=INV.VENDOR_ID
JOIN invoice_line_items ILI
ON INV.invoice_number=ILI.invoice_number
where line_item_amount > 2000
and invoice_date between '2014-7-1' and '2014-7-31'
and (invoice_number =9 OR invoice_number =2)
order by Invoice_Date

I am getting this err

Error Code: 1054. Unknown column 'ILI.invoice_number' in 'on clause

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

If you have any doubts/errors, please give me comment...

Please check once whether invoice_line_items table has invoice_number column exists or not, it is a foreign key which is referencing INVOICE table, otherwise please provide screenshot of invoice_line_items table schema

SELECT vendor_name as vendor, concat(first_name, ' ', last_name) as Contact, DAY(invoice_date) as ofday, invoice_date, SUBSTRING(invoice_number, 3,2) as thirdFourth, line_item_amount,round(line_item_amount*.15, 2) as Commission

FROM vendors v JOIN vendor_contacts vc ON v.vendor_id = vc.vendor_id

JOIN INVOICES INV ON V.VENDOR_ID=INV.VENDOR_ID JOIN invoice_line_items ILI ON INV.invoice_number=ILI.invoice_number

WHERE line_item_amount > 2000 and invoice_date between '2014-7-1' and '2014-7-31' and (INV.invoice_number =9 OR INV.invoice_number =2)

ORDER BY Invoice_Date;

Add a comment
Know the answer?
Add Answer to:
Hi this is for SQL Use the AP database Vendor name from the vendor table Vendor...
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
  • We will use a simple database composed of the following tables: CUSTOMER, INVOICE, LINE, PRODUCT, and...

    We will use a simple database composed of the following tables: CUSTOMER, INVOICE, LINE, PRODUCT, and VENDOR. This database model is shown in Figure 1. The database model in Figure 1 reflects the following business rules: - A customer may generate many invoices. Each invoice is generated by one customer. - An invoice contains one or more invoice lines. Each invoice line is associated with one invoice. - Each invoice line references one product. A product may be found in...

  • MULTIPLE CHOICE QUESTIONS for intuit quickbooks Which form should be used to pay a vendor for...

    MULTIPLE CHOICE QUESTIONS for intuit quickbooks Which form should be used to pay a vendor for a cash purchase? Write Cheques Pay Vendor Pay Bills Enter Bills How are the bills to be paid listed by default? By date due Alphabetically by vendor name By invoice number By amount due Where is the Vendor List located? On the Home window In the Company Snapshot In the Vendor Centre On the Company Menu When entering vendor information, which key should you...

  • Form A Mid-Term Exam In ajoin, when using the ON keyword, column names need to be...

    Form A Mid-Term Exam In ajoin, when using the ON keyword, column names need to be qualified only A in inner joins B. in outer joins c when the code is confusing D. when the same column names exist in both tables 7. Referring to the following code example and the data model the total number of rows returned by this query must equal SELECT vendor name, Invoice number FROM invoices LEFT JOIN vendors ON Invoices. vendor id = vendors.vendor...

  • SECTION B: SQL Data Manipulation Language 1. The following are parts of tables from customer sales...

    SECTION B: SQL Data Manipulation Language 1. The following are parts of tables from customer sales databases schema at the AWIE Sdn. Bhd. Company SALES CustID Date SaleAmount 2. Jun 2014 100.22 CUSTOMER CustID FirstName LastName DOB Phone 1 July 2014 909.95 어 1 John Smith 2/4/1968 012 222-2222 3 July 2014 522.95 2 Steven Goldfish 4/4/1974 013 455-4545 3 Dec 2014 100.00 3 Paula Brown 5/24/1978 017 323-3232 4 Smith 4 James 20/10/1980 010 323-8888 Dec 2014 555.55 a)...

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

  • #1) Display Last Name, First Name, DonorId, Fundname, TotalPledged from the donor’s database (you may need...

    #1) Display Last Name, First Name, DonorId, Fundname, TotalPledged from the donor’s database (you may need to use donor and pledge tables to get the information) for Donor ID 59034. (Your results window should have 3 rows) #2) Display all records from the PurchaseOrderHeader from the AdventureWorks Database that were sold by Employee 261 (Your results window should have 401 rows) #3) Display salesorderid, orderdate, totaldue, and territory name from salesorderheader and salesterritory for all totaldue that are greater than...

  • I am working on multi-table queries for my SQL class using a premade database, which I...

    I am working on multi-table queries for my SQL class using a premade database, which I have included screenshots of. I received assistance and was able to complete a good number of the queries but the bolded ones seem absolutely impossible to do?? How do I write a query for the bolded questions?? I've scoured my textbook and notes and cannot get anything I try to successfully produce results. 1. List all current reservations with the trip ID, customer’s first...

  • If possible please just send the SQL statement. Thank you Each question within deliverable 3 must begin on a new page and be sure to document the question as the title of each item at the top o...

    If possible please just send the SQL statement. Thank you Each question within deliverable 3 must begin on a new page and be sure to document the question as the title of each item at the top of each page. Also, using a 12-point font, include the SQL statement and then provide a screen shot of each query. The screen shots must include both the SQL statement and the results for each item below based on the data entered in...

  • This code must be in SQL - Run the script provided with the assignment. This will...

    This code must be in SQL - Run the script provided with the assignment. This will create the tables used for this assignment. Write the necessary SQL commands to perform the required actions. Run the queries to obtain results from the database. (Make sure all columns returned have proper headings.) 3 2 In a single row show the following values: how many unique manufacturers are in the products table. What is the most expensive price per unit in the products...

  • 484 Core Concepts of Accounting Information Systems a. Using Access, create an employee table sim- ilar...

    484 Core Concepts of Accounting Information Systems a. Using Access, create an employee table sim- ilar to the one shown in Figure 15-4. Create created. (Hint You can use the aforemen- tioned expression for the department code as a validation rule.) at least one record for this table b. Create validation rules for the listed restric tions and an accompanying validation text for each. Document your work by provid- ing a table outlining exactly what rules you c. Test each...

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
ADVERTISEMENT