Find Jobs
Hire Freelancers

debug SQL Statement

$30-5000 USD

Closed
Posted over 20 years ago

$30-5000 USD

Paid on delivery
The place to find the database for the SQL Statement is [login to view URL] There are 6 tables. The relationships between the tables are these: itemsown.inventory=[login to view URL] itemsold.inventory=[login to view URL] itemsold.invoice=[login to view URL] inventory.id=[login to view URL] exceptions.id=[login to view URL] exceptiondetails.exception=[login to view URL] Here is the statement I have so far which is almost correct but not quite. newdate=DateAdd("d", "-30", Now) sqls="SELECT [login to view URL], [login to view URL], [login to view URL], [login to view URL], Sum([login to view URL]) AS ItemsSold, [login to view URL], (SELECT Sum([login to view URL]) FROM itemsown WHERE [login to view URL] = [login to view URL]) AS ItemsHaveInStock" sqls=sqls & " FROM inventory INNER JOIN itemsold ON [login to view URL] = [login to view URL] where [login to view URL]>'" & newdate & "' AND itemsold.shouldhome='y'" sqls=sqls & " GROUP BY [login to view URL], [login to view URL], [login to view URL], [login to view URL], [login to view URL], [login to view URL] UNION ALL SELECT [login to view URL], [login to view URL], [login to view URL], [login to view URL], '', null, (SELECT Sum([login to view URL]) FROM itemsown" sqls=sqls & " WHERE [login to view URL] = [login to view URL]) AS ItemsHaveInStock FROM inventory WHERE NOT EXISTS (SELECT [login to view URL] FROM itemsold" sqls=sqls & " WHERE [login to view URL] = [login to view URL] AND [login to view URL]>'" & newdate & "' AND itemsold.shouldhome='y') ORDER BY [login to view URL]" The only problem is if a left side sells, but we have a right side, it shows the sell and shows we had the left side even though we did not. The example is part number 8-04. We sold a left side. There is no left side in stock. In this case, it should show 2 entries. One to show we sold a left side with none in stock and another one to show we sold 0 of the right side but have one in stock. Everything else is fine. What this statement does is shows what needs to be ordered. It is used with another formula to determine whether to show on the page (if number sold is greater than the number we have in stock). Below is information from the previous bid request. See deliverables for more information. ## Deliverables The completed SQL Statement to account for the side sold and the side I have in inventory. If there is no side, then everything is correct. Otherwise, if there is more than one side, show both. Even if its 0 sold and 0 in inventory for the statement. If the structure needs to be changed, that is fine as well. if an inventory item is in the itemsold table but nothing matching in the itemsown, then show it as null. The statement should return all the sales (count them) from the last 30 days. If nothing corresponds to the itemsown, then show that column as null. Also, from the itemsold, it should only show where shouldhome='y' The information retrieved should be something like this Inventory Number, Items Sold, Side, Items Currently Have For this sample, just show all the ones after 10/07/03. I can change it later to show for the last 30 days. The inventory number needs to be the [login to view URL] needs to group by [login to view URL] itemsold should count how many sold of the inventory item. items currently have should either be 0 if the current amount is 0. For the itemsown, no sum function is necessary. It needs to be grouped by side as well. It may or may not be null. The purpose of this is to show based on the 30 day sells, what items needs to be ordered. If there is one with a left and a right, show them twice. Let me know if you have any other questions. The statement needed will be similar but take into account of what side was sold and compared to what side I have in stock. ## Platform SQL Server 7.0, Access, Windows 2000
Project ID: 3022627

About the project

6 proposals
Remote project
Active 20 yrs ago

Looking to make some money?

Benefits of bidding on Freelancer

Set your budget and timeframe
Get paid for your work
Outline your proposal
It's free to sign up and bid on jobs
6 freelancers are bidding on average $195 USD for this job
User Avatar
See private message.
$68 USD in 1 day
4.9 (137 reviews)
7.2
7.2
User Avatar
See private message.
$3.40 USD in 1 day
4.5 (18 reviews)
3.7
3.7
User Avatar
See private message.
$12.75 USD in 1 day
5.0 (17 reviews)
3.4
3.4
User Avatar
See private message.
$21.25 USD in 1 day
4.5 (3 reviews)
1.3
1.3
User Avatar
See private message.
$255 USD in 1 day
0.0 (1 review)
0.0
0.0
User Avatar
See private message.
$807.50 USD in 1 day
0.0 (0 reviews)
0.0
0.0

About the client

Flag of AUSTRALIA
Sydney, Australia
5.0
781
Payment method verified
Member since Apr 9, 2002

Client Verification

Thanks! We’ve emailed you a link to claim your free credit.
Something went wrong while sending your email. Please try again.
Registered Users Total Jobs Posted
Freelancer ® is a registered Trademark of Freelancer Technology Pty Limited (ACN 142 189 759)
Copyright © 2024 Freelancer Technology Pty Limited (ACN 142 189 759)
Loading preview
Permission granted for Geolocation.
Your login session has expired and you have been logged out. Please log in again.