Hello dear MySQL users! i try to solf this since a while but everything i tried does not seem to work. I’m sorry if somewhere is already an answer for that but i know know how to search for. Its not so easy to explain in words so i use this table (called tbl ) to explain it: ID SerNo
Tag: greatest-n-per-group
How to get the latest date time record in an sql query with a where clause?
I have two tables : RO_LAMEL_DATA and RO_MAIN_TABLE. RO_MAIN_TABLE includes all the serial numbers (serial_nr) for the productions which have a record key (record_key). RO_LAMEL_DATA has several records (on the same day) for each record key such as machine status (machine_status) with a date time value (pr_date_time). I want to get the latest machine status of one production. For this
Select only newer records among the result of a query that extracts duplicate rows in a db
I have a db where I can have multiple rows with same field “aid” (it’s a sort of historical changelog of same items). With the following query, I’m extracting rows with same aid orderd by descending date: That should be a child table related to a father layer (made by a postgres materialized view that shows only newest aid records)
How can I unite these two related queries?
I have this query to check if a person is a customer or have been: And I have this other query to get the locations: How can I unite them and show person location as a single row on the first query? Answer If I follow this correctly, you can use lateral joins: As commented already, your original first query
Oracle SQL: Transfer certain records from one table to another filtering rows based on condition
Need to transfer certain records of some columns from Table1 to Table2 but filtering rows based on condition. Lets say Table1 looks like as shown below, has many columns in it. In Table2, need to insert rows from Table1 based on following: First, select A, B, C, D, E, F from Table1 where D=’xyz’ and E=1; and on the result
Get the Defect Type with the maximum Total Defect Qty
I have the following query which gets the sum of defect quantity per Defect Type : SELECT [Defect Type] ,YEAR([Date]) AS YearOfDefect ,SUM([Total Defect Qty]) AS [Sum] FROM SupplierQuality GROUP BY […
Limited By Value Postgresql query
I have a couple of rows where values in one column are repeating and I need to get a couple of rows where every value is limited by const. For example, i have this rows (1, ‘a’) (2, ‘b’) (3, ‘a’) (4,’…
How to fix my postgres function syntax to fit a user parameter
I’m trying to make a postgreql function, I’m a little confused on which syntax format to use when I’m passing a select statement that takes in a parameter (this parameter can be a string or a list of …
How to write this SQL query more elegantly ( joining + max query )
Ok I am using the following example from w3school https://www.w3schools.com/sql/trysql.asp?filename=trysql_select_all and I want to get the date in which the amount was ordered This works but my guts tell me I need to use joining or having ?? Answer You want the date of the order that has the maximum quantity. It does not look like you do need two
d6 delta query – get the latest entry
I’m working on a query but I’m running into an issue with deltas and getting the latest info. If I have a table as such…. I’d like to get results like: I want the latest delta that has a value per ID. I’m writing this in postgres but running into some issues. Any suggestions? Answer You can get the largest