I have a table that gets loaded with data. It SHOULD NOT contain duplicate ID’s, but it is not a perfect world, people make errors and duplicates occure. My table looks like this, but with many, MANY …
SQL DB2 – How to SELECT or compare columns based on their name?
Thank you for checking my question out! I’m trying to write a query for a very specific problem we’re having at my workplace and I can’t seem to get my head around it. Short version: I need to be …
update one row where it has multiple rows
I have below example table (ID is the primary): ORGTable: id | Type | Info —-+———+——- 1 type1 info1 1 type2 info2 1 type3 info3 2 type4 info4 2 …
How to create id field with auto increasement while using stored procedure?
I have this stored procedure. How can I select a variable as a field that can +1 value in every row of results of sp? I need it for making a virtual id field. please help me. CREATE DEFINER=`root`@`…
How would I insert the same row with all the different subquery values at the same time, almost like an iteration over the subquery?
CREATE TABLE messages (messageid INTEGER PRIMARY KEY , message VARCHAR(150) , sender VARCHAR(40) , recipient VARCHAR(40)) CREATE …
How to get all items that has added action but wasn’t deleted
I have an Activity table in which user’s activity on actions is stored. There is two type of actions in column type that are required to check: add_favorite remove_favorite So same object can be …
Maybe simple – Change ID with real name from another table
I hope you can help a lost person in SQL 🙂 Making this SQL query: SELECT c.CompanyName, c.ClientNumber, obo.EndMonth, ob.EndDate, ob.ClosedBy, ob.ClosedOn, obc.IsActive, obc.CheckPointTypeFk,…
How to prevent logical duplicates in a unary one to many SQL relationship table
In a non directional unary relationship what would be the best option to prevent logical duplicates? E.G. Main table ID — 1 2 Relational table ID1 ID2 ———– 1 2 2 1 Entry two …
How to implement JPQL query?
I have working query in PostgreSQL: select s.id, s.seat_number as available_seat, s.row_number as available_row, rm.room_name as screening_room from seats s join rooms rm on rm.id=s.room_id …
Query returns multiple id’s
I have a query that finds the most frequent numbers in multiple columns (named S1, S2, S3, S4, S5 and S6. The query seems to be working pretty good, but it doesn’t count the total number per id in the …