Skip to content

Tag: postgresql

Calculate percentage of students SQL

How to calculate percentage of students with higher mark than average for each course? Assume I have a table (avg_marks) with average marks for each course and number of students in the course: I also have a table (enrolments) with all courses, students enrolled in those courses and their mark for the course:…

Perform a particular ILIKE query on Postgresql

I have a problem with a query in Postgres. I have a column with values such as: id@@@Name1@@@other text@@@other_text@@@other_text@@@CODE@@@other_text### id@@@Name2@@@other text@@@other_text@@@other_text@@@CODE@@@other_text### id@@@Name3@@@other text@@@other_text@@@other_text@@@CODE@@@other_text### Each row ca…

Order By two columns but have one order

This question is sequelize specific but I’d figure if I found a way to do in SQL then I could find a way to do it in sequelize I need for the request to be ordered back by user.fullname which is joined by using include and by mockUser.fullname which is a JSON field. One important thing to keep in mind

Update SQL database registers based on JSON

I have a table with 30k clients, with the ClientID as primary key. I’m getting data from API calls and inserting them into the table using python. I’d like to find a way to insert rows with new clients and, if the ClientID that comes with the API call already exists in the table, update the existi…