Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

I need help with a SQL query for the days it takes to ship an order that can be matched to an individual sales rep.

I need help with a SQL query for the days it takes to ship an order that can be matched to an individual sales rep. Example if the order date was 2/17/2019 and the invoice date was 2/19/2019 it took 2 days to complete and ship the order.

The output wold look like the following

image text in transcribed

Some things I got so far.

I believe in order to get the date between the orders this should do the trick. DATEFDIFF("d" , [order table]. date created , [invoice table].invoice date) As turnaround

I also can use MAX([invoice table]. sales rep) AS Rep_ID to count each order a sales rep is placed on.

The tables im joining will include, customer, orders, invoice. The customer's table joins invoice and orders based customer ID and orders and invoice link on order #.

sales_rep ID is a value in customer, orders, invoice

I'm geting stuck on how to group everything

Thank you

Edit: I'm not sure how I would provide a structure for my database. If you could provide a setup of how you would go about this using your own data. So more info. I need the query to count the days between when the order was created to when its shipped and based on the column of 1's, 2's, 3's and 4+, count how many times the number appears and give a result like the table above.

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database Processing

Authors: David Kroenke

11th Edition

0132302675, 9780132302678

More Books

Students also viewed these Databases questions