Skip to content

Find the lowest score after the first Highest Score

I am looking for a SQL query. Table 1: Source Table Table 2: Result Table Attached the patient table. Here I want to find the Highest Score, Highest Score Date, Lowest Score and Lowest Score Date of …

elect data from related tables with duplicate columns

I have 3 tables. news rubrics parent_id is key for id parent in table rubrics. And “news_rubriks” How I can select news which apply to rubrics.id and rubrics.parent_id ? Answer If I understand correctly, you want to apply a filter to both the rubrik id and the parent. Say if you are searching for …

Select when two tables reference the same table

I have two tables, tSellers and tBuyers. They both have FK to a table tCity. How do I join and select city name from a buyer and a seller in a order table? Expected output: Answer To expand on @jarlh ‘s comment: Example of joining on City table twice, once for Seller (to get the city of the Seller), and

Case Statement within in Statement in MS SQL

I want to compare two different tables in IN statement based on condition. SELECT DISTINCT cts.ContactType ,ISNULL(ctl.[Description], CONCAT(‘Unknown Contact Type: ‘,cts.ContactType)) …

SQL Nested Joins (Case Statement and Join)

Hive DBMS; Two tables — A and B Table A Table B Question –> Trying to execute a query where: Join table A with table B, first on prnt_id, if it’s “unknown”, then join on sub_id, if that is “unknown”, join on ac_nm Desired Output: Answer You must use LEFT joins of T…

Postgres declaration type for multiple rows

I have a postgres function that uses a %ROWTYPE declaration. When I execute this function I get a failure about returning more than one row “code”:”P0003″,”message”:”…