Skip to content

Compare records in same table using self join

I am looking to get Permanent employee who has joining date greater than manager. This is what I tried till now, but I get zero records. I am expecting ouptut as Epmoyee with Id 9 as it has joining year(2019) greater than both the managers(2017 and 2015) Answer The join condition on id is the problem; this is…

How to select and join field with max date?

I have two tables joined on RECID and AAATRANSPORTORDERRECID : AAATRANSPORTTABLE AAALTLCHANGEREQUEST I need to select the record shown from AAATRANSPORTTABLE and join the AAALTLCHANGEVALUE value for the most recent CREATEDDATETIME from AAALTLCHANGEREQUEST. My query is as below: It produces these results: My d…

SQL Select only missing months

Notice the 2017-04-01, 2018-02-01, 2018-07-01, and 2019-01-01 months are missing in the output. I want to show only those months which are missing. Does anyone know how to go about this? Query: …

MySql query to check list of ids if they are friends with me?

So I have a list of ids(userId’s) that was found using a sql command that I want to check with my friends table to see if they are indeed friends with myself, a userid I will provide with, and have a column that will represent if they are and also group them if they are my friend and not my