Skip to content

Sort MySQL query with multiple joined tables

My query uses left join to fetch multiple values from the table objects_values. I’m having trouble sorting the results the way I want; if ASC, then show the objects with the lowest attribute values first, and if DESC, show the objects with the highest attribute values first. I have actually managed to g…

Sum By Group in Access 2016 Query

I have a query that returns the following data: I am trying to adapt it to sum the total number of runs at each venue. I have come up with the query below but there are two issues: it is not summing by venue it is summing all runs; it takes a very long time to run. Can anyone see

List of Record type matching issue Oracle

I want to check if a workspace is not available in all_workspace table then create new workspace. My requirement is if p_workspace is not matching the list of value of v_workspace then it should create new one. It gives me error after creation. If I run that workspace individually then its working. but when I…

SQL Informix advanced query

Let me try to explain what I want to do with my data. Structure of my data is as follows: I have 3 columns: date, id, and stage. Stages can be different numbers, but I’m interested in showing specific transition of some id from stage -1 to stage 1. Please see the example below. I have an id that was

Select data from multiple existing tables dynamically

I have tables “T1” in the database that are broken down by month of the form (table_082020, table_092020, table_102020). Each contains several million records. There is a second table “T2” that stores a reference to the primary key of the first one and actually to the table itself only…

SQL, group multiple rows into 2 rows and make one row

I have such a table Dates are subject to change, I want to group them in two rows. Dates range may be a maximum of 15 hours. My expected output is Answer Assuming every start date always has a matching end date, we can try: Here we are using pivoting logic along with the modulus of ROW_NUMBER to figure out

get one record at a time from joint table

I want to get a record from a joint table at a time. But I don’t hope the tables are joined as a whole. The actual tables are as follow. By specifying a cluster_id, I want to get one content name at a time where contents.status=2 and (contents name, cluster_id) pair is in content_cluster. The query in s…