October 22, 2024
Chicago 12, Melborne City, USA

SQL

Structured Query Language (SQL) is a language for querying databases. Questions should include code examples, table structure, sample dat

SQL

How to pair up the same strings in two table where in one of them they have a '?' replacing some of the characters?

I have names of people in a table as primary keys and I have them in another as foreign keys except in this second table they have been occasionally recorded faultily, with a ‘?’ symbol replacing a character. I’m looking to eventually update this second table with the correct names, but for now I would

Read More
SQL

Cannot perform Merge: multiple source rows matched in Delta Table

I am facing an issue while performing a MERGE operation on my Delta table. The error message I receive is: Cannot perform Merge as multiple source rows matched and attempted to modify the same target row in the Delta table in possibly conflicting ways. I have verified that there are no duplicates in the primary

Read More
SQL

Create a MS Access Pivot Query that returns rows even if there are null values

I’m trying to create a pivot table in MS Access based on an Employee List table, a Skills list table, and a table that contains data on what employee has what level of training for each skill. The table should return default values if there is no row found in the still level table. Employee

Read More
SQL

Two updates to two tables

I have to update two tables UPDATE TableA SET a="a", b = 'b', date = GETDATE() WHERE c="c" IF @@ROWCOUNT = 0 INSERT INTO TableA (c, a, b, date) VALUES ('c', 'a', 'b', GETDATE()) UPDATE TableB SET d = 'd', date = GETDATE() WHERE e="e" AND f="f" IF @@ROWCOUNT = 0 INSERT INTO TableB (e,

Read More
SQL

Unable to publish data into SQL server using SSIS

I am trying to publish a locally stored csv table to SQL server using SSIS. I have created a table in SQL server using the below query on SSMS. use sample_superstore drop table dbo.orders; create table dbo.orders( "Order_ID" varchar(50) , "Order_Date" date NULL , "Ship_Date" date NULL , "Ship_Mode" varchar (50) , "Customer_ID" varchar (50)

Read More
SQL

Left join to a Date range + SQL Math with Dates

second week working in SQL and data. I am commenting/documenting views we have in our database and I am so lost on this specific view. I have never seen a join into a date range and am quite puzzled by it. As well as there’s some math involving dates that I can’t wrap my head

Read More
SQL

Required suggestion to improve performance of C# methods

I am working on code optimization task below is detail code public class UserPrivileges { #region Properties public int UserId { get; set; } public int NPSiteId { get; set; } public string UserName{ get; set; } public bool IsPlaybackPortalAdministrator { get; set; } public Dictionary<int, LegacySitePrivileges> Permissions { get; set; } public string LoginName

Read More
SQL

How do I prevent duplicate rows in Postgresql while using COUNT and partitions?

first time question asker here and pretty new to SQL. I’m doing a project in postgresql and pgadmin 4 (if that matters) and I’m getting duplicates in my ‘title’ and ‘title_mo_rentals’ fields when using COUNT and inserting. Here is my table: CREATE TABLE detailed_report ( rental_id INT PRIMARY KEY , store_num INT , rental_year INT

Read More
SQL

Spring Jpa Update: Can not issue data manipulation statements with executeQuery()

I have a method in my Spring Boot application that updates the manager for a list of resources based on their IDs. The method is defined in a JPA repository as follows: @Query(value = "update resource set manager_resource_id = :resourceId where id in (:ids)", nativeQuery = true) void updateCurrentManager(@Param("resourceId") final String resourceId, @Param("ids") final Set<String>

Read More
SQL

Joining 2 tables but only show values from 2nd table once in 1st table

I’ve been racking my brain trying to solve this problem. I’m using Presto SQL. I have 2 tables: trx (transactions per day): | date | usage | deposit_id | | -----------| -------- |------------| | 2024-08-12 | 2,500 | DEP001 | | 2024-08-14 | 3,500 | DEP002 | | 2024-08-15 | 3,500 | DEP002 | deposit

Read More