Libreoffice Base - Triggering stock table deductions from orders table - sql

I'm working on a DB that consists mostly of two tables. One with our stock of memorial markers, and the other where I keep a running list of ongoing and completed orders.
When I change an ongoing order in the Orders table to completed I would like to have one of the corresponding memorial markers deducted from that size category in the stock table.
I've mostly been building this using the form designer and wizards but I am comfortable with coding, though I'm not super familiar with SQL. Some pointers in the right direction should to get me going should help. I've been searching around but keep getting results for other things.
Thanks for your time

Related

SQL - How do I expand a dataset to do a cohort analysis?

This is my first post so apologies if something is posted incorrectly - please let me know and I will fix it.
I am trying to build a SQL query in bigQuery that creates a cohort analysis so I can see how many customers have been retained over time by the month they joined (their cohort).
I work in insurance, so we have data on customers, when they joined, and any time they changed the policy (e.g., when they added a car to their coverage), but I do not have it laid out as every month of premium. The data is as follows:
Data vs how I need the data
Do you know how I could fill in the missing months?

Use domain of one table for criteria in another in ms Access query?

I am trying to create a report that displays 3 different numbers for each of my projects.
Contract Hours - Stored in projects table, 1 to 1 relationship
Worked Hours - Stored in linked table that will be updated using an external website reporting feature that will contain only data for the dates that are to be displayed in the report, one to many relationship needs to be a sum
Allocated Hours - Stored in a table in my database called allocations and contains data for all dates, one to many relationship needs to be summed.
Right now i have it set up in a way that the user has to type the data range for the report every time it is run, however the date range only actually applies to the Allocation data because the worked hours data comes filtered and the contract data is one to one.
What I would like to do is set up a query that can see the domain of the worked hours and apply it as a date criteria for the allocated hours.
I have attempted to use max and min values of the Worked hours and tried to get creative but I'm actually not even sure if this is possible because I cannot see any simple solution (although I know it should be possible and fairly simple)
Any help, suggestions, or recommendations are appreciated.

Microsoft Access Auto Rounding an Average Value from a query

I'm very new to Microsoft Access and I've run into a bit of a conundrum. I'm building a basic Access database that can help my Dad use past invoices to quote future jobs. I really only have two objects I'm working with. An invoice Table that hold all the costs that we paid for specific metals in 2013 and a Form I'm making that pulls information from that table. In my basic table I have a Currency field called PPLB(Price Per Pound). Now throughout the year we sometimes buy the same metal multiple times and if you know anything about metal, you know that the amount of metal you purchase sometimes affects the price that you pay. So in my Quoting Form I have a Query that looks like this->
SELECT DISTINCTROW Avg(MAT_QuickBookInvoices_2013.PPLB) AS [Avg Of PPLB]
FROM MAT_QuickBookInvoices_2013
GROUP BY MAT_QuickBookInvoices_2013.Material, MAT_QuickBookInvoices_2013.[Material Subtype], MAT_QuickBookInvoices_2013.Spec, MAT_QuickBookInvoices_2013.Shape, MAT_QuickBookInvoices_2013.Sizes
HAVING (((MAT_QuickBookInvoices_2013.Material)=[Forms]![MAT_QuoteTable]![Mat_CB]) AND ((MAT_QuickBookInvoices_2013.[Material Subtype])=[forms]![MAT_QuoteTable]![SubType_CB]) AND ((MAT_QuickBookInvoices_2013.Spec)=[forms]![MAT_QuoteTable]![Spec_CB]) AND ((MAT_QuickBookInvoices_2013.Shape)=[forms]![MAT_QuoteTable]![Shape_CB]) AND ((MAT_QuickBookInvoices_2013.Sizes)=[forms]![MAT_QuoteTable]![Size_CB]));
I know that's long but what it's doing is grouping the different type of metals into their most common grouping using Combo Boxes in the Quote Form and then finding the average price for that group. So now the problem. When I run the query it pulls up the correct price but when it transfers to the combo box it rounds price to the nearest whole dollar. How can I change or correct this? I've tried changing and formatting the source table as a double instead of currency and this hasn't helped. Any hints at all would be appreciated.
On the Property sheet for your comboBox, set the Formay property to Fixed. Then. immediately underneath that, set the number of decimals to 2 or 3 or whatever. That should do it.
Cheers -

MS Access tables that need to be in the listbox

OK, I have the worst VB class in the world. The friggin textbook has you do programming projects but the stupid book doesn't even explain everything required for the project. Oh yeah, the professor for the class doesn't help worth a crap (online schooling).
So needless to say, I have been struggling with the class for a very VERY LONG TIME...
Well, here's my request:
Here is visual representation of what is required
Now, I have been fighting this thing for MANY MANY hours and would like some tips and advice on how to get this stupid thing done. I usually get more specific when it comes to posting in this website except this time, it seems like I have a problem with EVERYTHING!!!
Here is the instructions:
"The database Microland.accdb is maintained by the Microland Computer Warehouse, a mail-order computer-supply company. The tables below show data in the three tables in the database. The table Customers identifies each customer by an ID number and gives, in addition to the name and address, the total amount of purchases during the current year prior to today. The table Inventory identifies each product in stock by an ID number and gives, in addition to its description and price (per unit), the quantity in stock at the beginning of the day. The table Orders gives the orders received today. Assume that it is now the end of the day. Write a Visual Basic program that uses the three tables to do the following two tasks:
Display in a listbox the items that are out of stock and those that must be reordered to satisfy today’s orders.
Display in a listbox bills for all customers who ordered during the day. Each bill should show the customer’s name, address, items ordered (with costs), and total cost of the order.
So, if any of you VB geniuses would like to tell me how to do some of this stuff, that would be absolutely awesome. Any kind of help will definitely make a difference for me.
(I'm assuming it's VB.NET) Here's some pointers on the bigger picture, you'll need Google to fill-in the details:
1) Establish a connection to your Access database using ADO.NET. Maybe do this in code or use the data tools in Visual Studio?
2) Write a query (in Access or plain SQL) to find the count of the distinct stock items that have been purchased today and subtract that from the count of the items in stock at the beginning of the day. Select the items where the count is zero or less.
You can use the visual builder in Access and save the query object, referring to this query object in code. Or you can copy the SQL generated by Access and use this with ADO.NET command objects.
3) Show the results of this query in a listbox. Either step through the DataReader adding items to listbox in code, or investigate databinding to your datasource.
4) Write another query that shows the data requested in step 2 in your question and then list those results in another listbox.
Try to get a little further with it and then respond with progress and further issues.

Recurring Orders

Hi everyone I'm working on a school project, and for my project I chose to create an ecommerce system that can process recurring orders. This is for my final project, I'll be graduating in May with an associates in computer science.
Keep in mind this is no where a final solution and it's basically a jumping off point for this database design.
A little background on the business processes.
- Customer will order a product, and will specify during checkout whether it is a one time order or a weekly/monthly order.
- Customer will specify a location in which to pick up their order (this location is specific only to the order)
- If the value of the order > 25.00 then it is accepted otherwise it is rejected.
- This will populate the orders_test and order_products_test tables respectively
Person on the back end will have a report generated for deliveries for the day based on these two tables.
They will be able to print it off and it will generate a list of what items go to what location.
Based on the following criteria.
date_of_next_scheduled_delivery = current date
remaining_deliveries > 0
Once they are satisfied with the delivery list they will press "Process Deliveries" button.
This will adjust the order_products_test table as follows
Subtract 1 from remaining_deliveries
Insert current date into date_of_last_delivery_processed
Based on delivery_frequency (i.e. once, weekly, monthly) it will change the date_of_next_scheduled_delivery
status values in the order_products_test table can either be active, hold, or canceled, expired
I just would like some opinions if I am approaching this correctly or if I should scratch this approach and start over again.
A few thoughts, though not necessarily complete (there's a lot to your question, but hopefully these points help):
I don't think you need to keep track of remaining deliveries. You only have 2 options - a one time order, or a recurring order. In both cases, there's no sense in calculating remaining deliveries. It's never leveraged.
In terms of tracking the next delivery date, you can just keep track of the day of the order. If it's recurring -- monthly or weekly, regardless -- everything is calculable from that first date. Most DB systems (MySQL, SQL Server, Oracle, etc) support more than enough date computation flexibility so that you can calculate this on the fly, as opposed to maintaining such a known schedule.
If the delivery location is only specific to the order, I see no use in creating a separate table for it -- it's functionally dependent on the order, you should keep it in the same table as the order. For most e-commerce systems, this is not the case because they tend to associate a list of delivery locations with accounts, which they prompt you about when you order more than once (e.g., Amazon).
Given the above, I bet you can just get away with 2 of your 4 tables above -- Account and Order. But again, if delivery locations are associated with Accounts, I would indeed break that out. (but your question above doesn't suggest that)
Do not name your tables with a "_test" suffix -- it's confusing.