I want to group by the records and that particular group if the condition matched then set final result like below For each group, I want to check the following condition Answer You can use conditional logic: Here is a db<>fiddle.
Follow the connections : recursive query
i have two columns of numbers. the goal is starting from a number f.e. 55, to extract all ‘connected’ numbers (starting with any of those numbers, should yield the same result) in this case all numbers shown here : 55,56,35,69,60,22,47,2,26 I use the following query : but I get back only those bac…
Different performance from SQL Server query from Management Studio vs EF Core 5
I wrote a simple EF Core query that makes a select on a table using some where clause to filter data: start date and finish date between the actual date and a field (DescrizioneCommessa) containing a value. To get the raw SQL I just execute the statement: And the resultant query is: I notice that it takes ver…
EF Core 5 failing while trying to update a foreign key which is also part of a unique Index
Like the title says, I am trying to update a foreign key and getting below error: The property ‘Student.APID’ is part of a key and so cannot be modified or marked as modified. To change the principal …
Repeat Rows certain amount of times for columns
I have this table: select * from db_table car city month_number Honda Boston 1 Honda Boston 2 Honda Boston …
How to cross join two tables in sql
So I need to cross join 2 tables but I cannot find a way to do so without receiving the error ORA-01427: single-row subquery returns more than one row ORA-06512: at “SYS.DBMS_SQL”, line …
What to use instead of DO_NOTHING to only delete one field?
I want to link two models like this class t_data(models.Model): receiver = models.TextField() file_desc = models.TextField() file = models.FileField(upload_to=’files’) another model : …
SQL error [21000]: ERROR: a subquery used as an expression returned more than one record
The Remesa table has a relationship N to 1 with EnvioRemesa, the issue is that I want to update my delete bit to 1 of the Remesa table, but only update the Remesa that have a EnvioRemesa id = 2. And it is failing me in the query since in the subquery it returns 2 matching records and tries to
SQL: IF OBJECT_ID() and IF EXISTS don’t work in conjunction with UPDATE statement
I am using SQL Server 2017, I have a View called Foo, what I’m trying to do is to check if Foo is a user-defined table, if Yes, do an UPDATE, else do not do anything. Here I check if the Foo exist and if it is a user-defined table (xtype=’U’). Since Foo is a View, so xtype=’U’ sh…
How do I update row in postgessql to ignore error?
I am trying to update thousands of rows in my table in postgres but I am getting a user does not exist error, hence my table is not updating. How do I update the rows in table to ignore any errors where a user does not exist in the user table If for example userid=3 does not exist, how do