sagadgfgfdgasdgagfdasd asdfgasg fdsgsgfs afdgsdfga
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…
Insert query: Column name or number of supplied values does not match table definition
This is a table that auto increments the ID, takes the time input, and sets the default of the total column as zero and the date column with getdate() So the only value that I have to insert is the time. However on insertion SQL Server gives me this error: Column name or number of supplied values does not mat…
Is start transaction always needed with Mariadb storedprocedure?
I have a mariadb database and a stored procedure. If a select statement is true then a delete query is done. Like this: My question is, do I need to place the start transaction at the beginning before the select statement or is the following possible? This second code doesn’t require a rollback and only…
How to check if two dates are the same with timestamp
I have two dates. One I get from the database, the other is which one I want to pass. How can I check if these two are the same? These are timestamp with time zones In this case they are the same. Answer
How can I query with NOT IN in a many-to-many relationship including NULLs
Given I have 3 tables and I need to retrieve all the rows where there is no relationship with a specific record and include the rows where there are zero relationships, how can I build this query? I need all books where the author Dewey (id = A2) has no relation at all. Because B4 has a relation with author
Invalid number when converting a date to another format
I have this query, and i am trying to format all dates for the two columns mentioned in the query below to the format mentioned: and i want to convert the results from timeone and timetwo to another date format DD-MM-YYYY HH:MIPM but when I run the query I got back invalid number. The datatype of the timeone …
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