Skip to content

Tag: postgresql

Order By Month Name – Postgresql

I followed this post Order by using month name in PostgreSQL but not success! I have a query (its working) and I just need to order the results by mont name. This is thr query I am using: I am trying: If i use order by mes_2021 Answer One trick is to use a window function on the date: This,

Check if a chat between 2 people exists

I have a chat system that handles group chats. A conversation can have many participants and the only distinction between group and non group chats is a non group chat will only have 2 participants. I want a query to check if a non group chat exists between 2 users. Conversations table Participants table To c…

how can I can running status from my table?

I have a below table which has multiple rows with same executionid and different status. How can I get the row which status is running, rows will be exclude if executionid associated with both running and completed status? Below image is the sample data : Expected result should be: Answer Using String_AGG() t…

SQL how can i detect if a value decrease over time?

Hi, how can i check who are the employees whose salary has fallen ? : I only want to fetch the name of employees whose salary has fallen Answer You can use the positional analytic function LAG() to find these rows. This is a standard SQL function that peeks at a previous row, according to a specific criteria.…