Skip to content

Tag: sql

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,

savepoint in sql

Can I rollback to a savepoint ( which was done before a commit ) in SQL ? Answer You can use the ROLLBACK TO SAVEPOINT statement only in the transaction. In MySQL documentation (https://dev.mysql.com/doc/refman/8.0/en/savepoint.html) you find: All savepoints of the current transaction are deleted if you execu…

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…