Skip to content

Change all bit columns to int with default value NULL

I have a database where we would store Yes/No questions as bits. However, as the project is going to a different path, we need to change all bit data types to int with default value NULL. Trying the following query, I get object is dependent of column error. To fix this I try doing: However, the fact that the…

Delete cascade Category child (Java Hibernate JPA)

I have this Entity to represent a Category system with a selfrelationship to get child categories: The problem is when I want to delete a category that has child categories. I want to delete all child categories but Java drops me this exception : Cannot delete or update a parent row: a foreign key constraint …

Joining table only once in SQL

I’m sure this is very basic, but I’ve hit a brick wall. First post here, long time reader. I’ve got two tables, one is a list of customers, one is a list of their activity by month. For some unknown reason, some of the data in the activity column is duplicated and it’s causing me error…

PL SQL Pivot: use different aggregates

I want to pivot sum(sales) per country as below. But the price column should be an average per shop. So, I would love to have this result: Desired Result: shop avg_price US CN 2 6 100 10 3 5 60 10 Current Result: shop price US CN 2 5 null 5 2 7 100 5 3 5 60 10 I