close ad
Help us test the new Databridge BETA with MySQLi support
open ad
View Menu

Technical Support Forums

Free, outstanding support from WebAssist and your colleagues

rating

Results based on a date range

Thread began 10/11/2010 2:14 pm by jbarron397794 | Last modified 10/27/2010 11:20 am by jbarron397794 | 1407 views | 12 replies |

jbarron397794Beta Tester

Results based on a date range

Hi, I now have my date range working, but how would I specify in either the recordset or the php code (or both) that I need results based upon just that date range? For instance, if an admin does a search of an item in the inventory db and wants specific information for how many of that item was sold in that specific date range, where would I implement this? And how?

Would I join tables and then write this in my query within my recordset?
How would I then get this information to display?
Would I need to use DataAssist to bind the results to my text fields?
Would I need to make a hidden search on my results page to produce the results I am looking for?

Thanks!

Sign in to reply to this post

Dave BuchholzBeta Tester

If you are using DataAssist you can use the excellent Search Wizard to set all this up for you.

See the using the dataassist search wizard solution recipe 02_dataassist_search.swf

Sign in to reply to this post

jbarron397794Beta Tester

Hi Dave,

Thanks for the response. I own all of WebAssist's extensions so yes, all of my reporting admin pages has been through Data Assist.

Does there happen to be a pdf of the instructions from this presentation anywhere?

Thanks!

Sign in to reply to this post

Dave BuchholzBeta Tester

look under solution recipes here dataassist/

Sign in to reply to this post

jbarron397794Beta Tester

Hi, I believe I have the query in my recordset ALMOST working.
Please take a look:

SELECT inventory.itemId, inventory.itemName, inventory.itemDesc, inventory.itemPrice, inventory.itemQty, inventory.itemSize, inventory.itemColor, inventory.partNum, inventory.prodLine, orders.OrderDate, orderdetails.DetailItemId, orderdetails.DetailQuantity, SUM(orderdetails.DetailQuantity) AS OrderTotal, (OrderTotal*inventory.itemPrice) AS OrderQty, (inventory.itemQty*inventory.itemPrice) AS InventoryTotal
FROM orderdetails INNER JOIN inventory ON orderdetails.DetailItemId = inventory.itemId INNER JOIN orders ON orderdetails.DetailOrderId = orders.OrderId
GROUP BY orderdetails.DetailItemId, orders.OrderDate
ORDER BY itemName ASC

I need to first add together the values of the quantity sold for each of the individual items and have it appear in one field that DataAssist created. I then need to multiply the sum of that by the item price to come up with a currency usage of what was sold in a certain date range. I also need for what is currently available in inventory multiplied by the price of the item to appear in another field. I have all fields set up and appearing, however it is not grouping it properly. I need to group these by item id's and instead it is displaying each line item on a separate line without grouping them.

I really like WebAssist and all of it's products. The technical support and professionalism that is portrayed is superb, but if I could make one suggestion it would be to consider adding a more complex query builder to your DataAssist and/or search wizard.

Sign in to reply to this post

Dave BuchholzBeta Tester

try grouping by the inventory id instead

Sign in to reply to this post

jbarron397794Beta Tester

Thanks for your response. I tried grouping by the inventory.itemId instead, but I still am coming up with the same result. Here is the query I am using now:

SELECT
inventory.itemId,
inventory.itemName,
inventory.itemDesc,
inventory.itemPrice,
inventory.itemQty,
inventory.itemSize,
inventory.itemColor,
inventory.partNum,
inventory.prodLine,
orders.OrderDate,
orderdetails.DetailItemId,
orderdetails.DetailQuantity,
(inventory.itemQty*inventory.itemPrice)AS InventoryTotal,
SUM(orderdetails.DetailQuantity)AS OrderUsed,
SUM(orderdetails.DetailQuantity*inventory.itemPrice)AS TotalUsed
FROM
orderdetails
INNER JOIN inventory
ON orderdetails.DetailItemId = inventory.itemId
INNER JOIN orders
ON orderdetails.DetailOrderId = orders.OrderId
GROUP BY
inventory.itemId,
orders.OrderDate

And here is what it is returning:

Speed Reducer catalog CAT03 586 10 2.5 25 1465 Literature
Speed Reducer catalog CAT03 586 25 2.5 62.5 1465 Literature
Speed Reducer catalog CAT03 586 25 2.5 62.5 1465 Literature
Speed Reducer catalog CAT03 586 3 2.5 7.5 1465 Literature
Speed Reducer catalog CAT03 586 2 2.5 5 1465 Literature
Speed Reducer catalog CAT03 586 5 2.5 12.5 1465 Literature
Speed Reducer catalog CAT03 586 2 2.5 5 1465 Literature
Speed Reducer catalog CAT03 586 15 2.5 37.5 1465 Literature
6000 Gearmotors catalog CAT6000 1426 5 2.5 12.5 3565 Literature
6000 Gearmotors catalog CAT6000 1426 10 2.5 25 3565 Literature
6000 Gearmotors catalog CAT6000 1426 3 2.5 7.5 3565 Literature
6000 Gearmotors catalog CAT6000 1426 2 2.5 5 3565 Literature
6000 Gearmotors catalog CAT6000 1426 5 2.5 12.5 3565 Literature

See how it is still displaying each line item separately? Any other suggestions?

Thanks!

Sign in to reply to this post

Dave BuchholzBeta Tester

take the orderDate out of the order by clause

Sign in to reply to this post

jbarron397794Beta Tester

That did the trick! Thanks!!!

I now have a total quantity of what was sold, a total price of the quantity sold and a price of the quantity still available for a specific date range.

Here is what the final query looks like:

SELECT inventory.itemId, inventory.itemName, inventory.itemDesc, inventory.itemPrice, inventory.itemQty, inventory.itemSize, inventory.itemColor, inventory.partNum, inventory.prodLine, orders.OrderDate, orderdetails.DetailItemId, orderdetails.DetailQuantity, (inventory.itemQty*inventory.itemPrice)AS InventoryTotal, SUM(orderdetails.DetailQuantity*inventory.itemPrice)AS TotalUsed, SUM(orderdetails.DetailQuantity)AS OrderUsed
FROM orderdetails INNER JOIN inventory ON orderdetails.DetailItemId = inventory.itemId INNER JOIN orders ON orderdetails.DetailOrderId = orders.OrderId
GROUP BY inventory.itemId
ORDER BY inventory.itemName ASC

Sign in to reply to this post

Dave BuchholzBeta Tester

no worries, glad it worked

Sign in to reply to this post
loading

Build websites with a little help from your friends

Your friends over here at WebAssist! These Dreamweaver extensions will assist you in building unlimited, custom websites.

Build websites from already-built web applications

These out-of-the-box solutions provide you proven, tested applications that can be up and running now.  Build a store, a gallery, or a web-based email solution.

Want your website pre-built and hosted?

Close Windowclose

Rate your experience or provide feedback on this page

Account or customer service questions?
Please user our contact form.

Need technical support?
Please visit support to ask a question

Content

rating

Layout

rating

Ease of use

rating

security code refresh image

We do not respond to comments submitted from this page directly, but we do read and analyze any feedback and will use it to help make your experience better in the future.

Close Windowclose

We were unable to retrieve the attached file

Close Windowclose

Attach and remove files

add attachmentAdd attachment
Close Windowclose

Enter the URL you would like to link to in your post

Close Windowclose

This is how you use right click RTF editing

Enable right click RTF editing option allows you to add html markup into your tutorial such as images, bulleted lists, files and more...

-- click to close --

Uploading file...