It’s well documented on StackOverflow how to find the whole data for the row with some max value in a column per some group identifier (SQL select only rows with max value on a column). But that given …
Tag: sql
SQL Pivot and get column row data
I have tables and data as below. Trying to get the Manufacturer and the questions they answered by joining and pivot but able to. Added the expected output at the end but no luck. Any suggestions are …
Oracle Apex update specific row of table
Hi i want to update a specific row of my oracle database via apex. So i need to reach/address the specific row via where clause. example entries: GATTUNG ART UNTERART ABART VARIETÄT AAA AAA AAA NULL …
SQL Query Inactive Users with last end date
This is a follow up from a question I asked about a year ago Old thread The answers I got then have worked fine but now I discovered that I need to tweak the query to be able to get the latest end …
Loop through JSON array in PLSQL 12.1
I have JSON array inside varchar DECLARE JsonArray varchar2(1000); arrayCars varchar2(1000); BEGIN JsonArray :={“Cars”: [{“name”:”Honda”, “color”:&…
Select Last Rows with Distinct Field
I have a table with the following schema: In this table only the id field is unique. I’m concerned with getting the rows containing the last X distinct itemid, ordered by date. For example, in the sample above, if I’d like to get the last 3 distinct itemid, I’d be getting the first 4 rows, s…
SQL show based on date condition
I have following query to start of with: I then get following table (only a snapshot for better desciption): I now have a problem: I only want to show the services where the service starting with ‘AAF21 OKN’ is first (by date). Patient ID: ‘Forløb10030’ is for example what i want. But …
Insert new records with several ids from another table
I have a table, which has 9 records with id = 1 – 9 (for example, there can be more than 20 ids). I have one varchar value = ‘premium’. I need to insert these values to another table, after this action I should have 9 records with id from the first table and ‘premium’ varchar in …
Firebird column unknown on SELECT AS
I have a table of calls and their durations: I want to select all numbers that called for over 500 seconds in total. My query uses SELECT AS to rename the SUM(…) field so I can reference it in the HAVING clause: When I run this query in Firebird SQL, I get the following error: Answer You can not use
Get pair-wise single row
I have some data in a MS SQL Server database. Sample data is: Sl ColumnA ColumnB 1 111 112 2 112 111 3 113 114 4 114 113 5 115 116 6 116 115 Now I need result like. ColumnA ColumnA 111 112 113 114 115 116 Notice here: In Sl 1 number Column A = Sl 2 Column B