Find Max Date from a Distinct Row Then Add Value to a Table Column

Quick disclaimer – I am familiar with Access, but a novice at MySql within Access.

I have a table with activity data that I pulled into a query to filter down to only necessary data. The query table has DateTime, Call, and Designator columns. The Call and Designators rows repeat numerous times. The Call is a numeric value which identifies a unique activity and there may be many Designators assigned to each Call. Within this query, I need to find the Max and Min DateTime values of distinct rows (based on the Call and Designator rows) and then add a "Start" value to a new column for the Min DateTime and "End" for the Max DateTime.

Once the Start and End times have been identified for each unique row (Call and Designator) I need to calculate the total time each Designator spent on each call. I assume that I may have to create another query to include DateTime, Designator, Call, Start Time, End Time, Total Time on a single row to generate reports. But, it would be much easier if it can all be done with one script on the same query.

I’ve been searching for the past several days and haven’t made any progress so I don’t have any existing work to show.

Expected Result

Thank you in advance!!

Populating a Junction Table in sqlite

Im a beginner in sqlite and I want to use sqlite in a database where I have three tables one as a junction table for the two tables. The two tables are named users and stocks table. I know that the user id in the users table will auto increment itself since it made it a primary key. Now in the stocks table I want it to increment it but it must start at 1 again if the stock is connected to another user which can be identified in the junction table.

Here is my schema enter image description here

And this is my idea on how I want my junction table to look like

enter image description here

Just delete 50.000.000 of rows on a PostgreSQL table and DB still very slow

sorry for my poor english.

I have a postgres DB runing on amazon RDS (db.t3.small), with django as a backend. i have made a mistake and created 50.000.000 rows. when i figure out (because queries on that table where ultra slow) i delete it all. but the queries i make on that table stills super slow. it only have 300 rows now.

i have to clean some cache? i have to wait something? the configuration of the RDS in aws is default.

the engine version of postgres is 12.5, also have postgis installed in it.

i check for vacuum issues and run this command:

SELECT relname AS TableName,n_live_tup AS LiveTuples,n_dead_tup AS DeadTuples,last_autovacuum AS Autovacuum,last_autoanalyze AS Autoanalyze FROM pg_stat_user_tables; 

the table with the problem says:

'appointment_timeslot', 1417, 0, datetime.datetime(2021, 7, 21, 18, 13, 8, 193967, tzinfo=<UTC>), datetime.datetime(2021, 7, 21, 18, 13, 30, 551750, tzinfo=<UTC>) 

check for indexes that Django creates automaticly on that table and i find 4

[ ('appointment_timeslot_pkey', 'CREATE UNIQUE INDEX appointment_timeslot_pkey ON public.appointment_timeslot USING btree (id)') 'appointment_timeslot_home_visit_id_62df4faf', 'CREATE INDEX appointment_timeslot_home_visit_id_62df4faf ON public.appointment_timeslot USING btree (home_visit_id)') ('appointment_timeslot_office_id_6871b47b', 'CREATE INDEX appointment_timeslot_office_id_6871b47b ON public.appointment_timeslot USING btree (office_id)') ('appointment_timeslot_time_range_id_715578fa', 'CREATE INDEX appointment_timeslot_time_range_id_715578fa ON public.appointment_timeslot USING btree (time_range_id)') ] 

Price change from the js table Woocommerce [closed]

I have created two additional fields to calculate the price. I now need to set this price in the cart.

This is the code that calculates the price.

jQuery(function ($  ) {  const priceList = [5, 10, 15, 20, 25, 30];  let numberFrom = 0 let numberTo = 0; let number = 0;   $  ('select[name="from"]').on("change", function(){     let optionSelected = $  ("option:selected", this);      numberFrom = optionSelected[0].index;      if(numberFrom != 0 && numberTo != 0) {         number = Math.abs(numberFrom - numberTo);         $  ('.woocommerce-Price-amount.amount bdi').text(`$  {priceList[number].toFixed(2)}zł`);     } });  $  ('select[name="to"]').on("change", function(){     let optionSelected = $  ("option:selected", this);      numberTo = optionSelected[0].index;      if(numberFrom != 0 && numberTo != 0) {         number = Math.abs(numberFrom - numberTo);         $  ('.woocommerce-Price-amount.amount bdi').text(`$  {priceList[number].toFixed(2)}zł`);     } });   }); 

I need the price taken from the table to be set for the client. Use AJAX for this?

Excel to HTML Table

I am trying to create an HTML table that reads in Excel file. At the rightmost column, is a checkbox column where we can select the rows we want. The user opens the file, and then reads it to a table.

 <body>         <h2>Data in excel file</h2>         <input type="file" id="input">         <table id="tdata">             <thead>                 <tr>                     <th>Name</th>                     <th>User ID</th>                     <th>Staff Type</th>...
Code (JavaScript):

Excel to HTML Table

Would a custom table make more sense than a CPT in this case?

I am building a "multi vendor" type plugin to extend Woocommerce. There will be two types of new user roles: Vendor, and Non-Profit Org.

Vendors can list their products on the site, and users can choose at the checkout page which "Non-Profit Organization" they would like to donate part of their purchase to.

Ultimately, I would like the site owner to be able to have a curated list of all transactions, meaning how much is going to the Non Profit, how much goes to the Vendor. Preferably in chosen increments (monthly, daily, by individual order).

What’s got me stuck is figuring out how to let the "Vendor" and "Non Profit Org" accounts VIEW their respective transactions as well.

I don’t know if I should make two custom post types (Vendor Orders, Non Profit Orders) and just list extra info as Post Meta, as well as finding out a way to make sure ONLY the user assigned to the role can view orders for that role (in other words, one non profit can’t see records of another non profit).

Or, I am wondering if it makes more sense to create a custom table, which lists all valuable information (amount going to vendor, amount going to non profit, etc…) and just write custom queries to list the information based on the current user ID.

Is it possible to set permission to other user for the table created by current user with PostgreSQL?

In PostgreSQL, created these 2 roles and grant different permissions to them.

create user user1 with login; create role operator; grant operator to user1;  create user user2 with login; create role readwrite; grant readwrite to user2; 

When created a table by user1, such as table1, user2 can’t use this table. It got permission denied.

Is it the right feature for PostgreSQL? If it is, how to make the table also can be used for user2?

How do I join rows from the same table with slightly different info?

We have a new sector of our company that is being put into our employee record feed. However this sector is listed as contractors as there are still parts of the sector that need access to systems that require domain access… so…

I have:

TABLE EMP

EmpID, email, INFO1, INFO2, INF03…

and for Tom Smith 5763, tom.smith@co1.com, blah blah, blah blah, blah blah…

and also for Tom Smith ZZ98401, tom.smith@co2.com, null, null, null…

Not everyone on the feed is like this, only about 10%. Most are in case number 2.

What I am looking for is the easiest way to equate the two rows associated with Tom and fill in as much info on Tom as I can because some fields come from one account and other fields come from the other. The only thing that can accurately make the two rows common is the beginning of the email address – this is standardized. So there should be a few thousand people (rows of duplicates) on my feed that I can combine if it can be done right.

I would also like to capture both EmpIDs somehow in the same row and both email addresses.

MySQL Table structure and data export – Script sequence is not correct

When I export the data and structure of my MySQL database to a file, I notice that the table sequences in the output file are not correct. For example the script of a child table is put before the master table. Incase of MSSQL that is not the case. Any idea how that can be corrected?

MySQL80 MySQL Workbench 8.0