A process was causing duplicate rows in a table where there were not supposed to be any. There are several great answers to deleting duplicate rows online. But, what if those duplicates with ID primary keys all have data in other tables tied to them? Is there a way to delete all duplicates in the first table …
Tag: sql
How to create nested tables in SQL Server
I don’t understand how to create nested tables. My project is about beer. I have different coolers for sale, and each has a capacity for n number of beers. Each cooler comes preloaded with beers, and …
rowCount for items over 45 days old
I have a table and use this to show me how many days the widgets have been in stock, this is the code I am using for this I have info boxes at the top of the screen giving me different widget info, what I wanted is one of these info boxes to give me a total of how many
Adding column based on partition by – Oracle
Table: Col1 Col2 Col3 43 1234 abc 42 1234 abc 41 1234 abc 35 1234 abc 34 5678 def Objective is to create …
Fetch multi-participant conversations with last message for each
I am trying to create a simple chat application database schema, and query the conversations. My current table setup is the following: So basically each conversation has its own title, and multiple participants. What I would like to fetch my conversations sorted by the date of the latest message in the conver…
Get a value from two tables
I am trying to get the value of the colum “name” from the clubs table. First table:(Clubs) id* name (what i need!!!) email password Second table:(club_posts) id club_id* zip_id kategory type stadt plz Controller: This is my query: The result is an array with ten values, but need only one. Answer C…
Promote a clerk if his salary is greater than 1000 and update his salary by 10%
Write a Parameter Cursor program that promotes CLERK who earn more than 1000 to SR CLERK and increase the salary by 10%. Pass CLERK as a parameter to the Cursor. Use cursor with Update Clause. My code: My code does the work but I don’t find it correct so can someone suggest an alternative? Answer You ca…
Selecting the record(s) with the “second” highest something
I have written the following SQL commands for retrieving data from a table called Employee. I was able to get the highest/maximum salary as well as the second highest/maximum salary, but I am having …
Matching and unlatching records in a single table sql server
I have procedure where I am getting data from my 1st temp table like below 2nd temp table like below Now I need to join this 2 temp tables to get all matching and unmatching data .My result would be like below But I am getting only matching data.Please help how to do Answer I think that’s a full join:
SQL select data based on a one to many relation
I struggle a little with the following database entity relations: I would like to create a query where I get all events for a user that is either the owner (item-user_id) or a participant (participant-user_id) I got back to native queries, cause they are more easy to try out. But the one to many relation betw…