Skip to content

Tag: sql

how to convert this sql query to liquibase query

I have table like this I need to delete all duplicated rows with equals A nad B value and lower C value after running sql script i need to have only this row with top C Value for every equals A and B columns this is the sql query i am using how to convert it to liquibase query Answer

Boolean value not being changed in database

Hey folks I’m having a problem with my code. For some reason when I try to change the value to false, it doesn’t reflect in my SQL Database. I debugged and it does get set via Java, but it doesn’t transfer over. I’m working on a notification service class and it sets the values on ther…

Combining Data from Multiple Rows in Simple Database

I am new to using SQL. I have constructed the following simple database, which has the ID of music albums and the number of copies bought. In the album_ID column, there are two pieces of data with ID 1. They have quantity_bought values of 10 and 4. Is it possible to combine these two rows into one row which h…

sql: query to find max count with extra columns as well

Input table:events GOAL I want max(distinct user) grouped by month column. my final result need two columns one is month and another one is max_count I need output similar to this I followed some approach Approach1: if i follow this approach, it is just giving me only max_count but i need month column as well…

Duplicates in pre-aggregated sub-query sql

I have two tables with many-to-many relationship. I am trying to get values from both of the table where UserId is unique (I’m joining these table on this value) I am rying to use pre aggregated query, but I get error Column ‘clv.ProbabilityAlive’ is invalid in the select list because it is …

Recursive SQL query for finding matches

I have 5 SQL Tables with the following columns: As input data I have employee_id and request_id. I need to figure out whether the employee has access to the request (whether he’s a manager or not) We cannot use ORM here since app’s responsiveness is our priority and the script might be called a lo…