Is it possible to have a Constraint but only when one column is set to a particular value. For example take this pseudo-code example of a President which checks to make sure there is never more than 1 …
Tag: sql
SQL query returns void in Spring Boot application but does not in H2
Good evening, I’m sure I’m missing something about how to write queries in a Spring Boot application and would appreciate correction. SQL query in h2-console: SELECT customer_id FROM customers WHERE …
Insert CSV file to already existing table within SQL Server
I have a .csv file that I must update to my already existing table within SQL Server. Is there a query other than a BULK INSERT that I can use for this? Here is the database and table: Backup Database …
update command C# DataGridView to SQL
I’m attempting to update a SQL table from C# project datagridview “Work_Table”. However when I attempt to make the update I get this error “Update unable to find TableMapping [‘…
Calling Procedure with ‘call’ function from within P/L SQL Script Oracle
I am not able to run this simple if/then statement in oracle database. (i think it is 10.x but not sure, seems to be an issue of my sql skill not db version). Can you help me figure out how to run …
presto replace multiple characters
I have a string and would like to remove a set of characters. Is there a better way than chaining multiple replace()? I came up with the following but it requires a replace() call for each character: This is a minimal example and I have more characters to escape so I was looking for a less verbose way of achi…
How to implement LIKE functionality in a grouped query that depends on an IN operator? [closed]
Closed. This question needs details or clarity. It is not currently accepting answers. Want to improve this question? Add details and clarify the problem by editing this post. Closed 2 years ago. Improve this question After some great interaction here in Stack Overflow I am able to implement queries to get al…
Dense Rank grouping by IDs
I am having trouble getting my DENSE_RANK() function in Oracle to work how I would like. First, my dataset: I am trying to use the dense rank function to return results with a sequence number based on the DATE field, and grouping by ID. How I want the data to return: The query I have so far: However, this ret…
Oracle Query With (BETWEEN Two Dates) Returns Empty Result Set
I have an Oracle SQL Query I am trying to run, but it keeps returning null value for the second query below but when I use the first query it returns a value. Please can someone help me check what I may be doing wrong in query 2? Note that the date column is in the Format 21/09/2020 10:00:00 AM
SQL Spark – Lag vs first row by Group
I’m SQL newbie and I’m trying to calculate difference between the averages. I want for each item and year calculate difference between months, but I want always substract current average – fist month …