i having an issue on changing the month according to the loop in where the clause i have used between function the month of todate function have to be changed according to the loop if a becomes 1 then the month in where clause has to be changed according to 1 if a becomes 2 the month have be changed
Tag: sql
Oracle SQL Trigger not getting created
I have a table passenger as shown below I am learning triggers and I want to create a trigger that updates charges as charges + 100 before a new insert is done. Here is the trigger I created. However, I am getting the error ORA-04079: invalid trigger specification. I have tried replacing new with :new, adding…
Postgres – Pick 1 max row instead of all max rows in the same month on a LOD (group by)
Hi have a data set which has product, site, station, date and some numerical fields such as sn_count, blob etc. Within every combination of product, site and station, if there are multiple entries for the same month from different dates, I want to only pick one row with max sn count in that month. The code I …
“WITH AS” Working in Postgres but not in H2 dabatabse
I am writing a single query to insert data into 2 tables using “WITH AS”. The query works fine on Postgres but on H2 database it is throwing syntax error. I have 2 tables. Table 1 has 2 columns — a Primary Key table1_ID and a table1_value column. Table 2 has 3 columns — a PK table2_Id …
Can’t remove duplicates from MariaDB 10
I’m having hard time removing duplicates from database. It’s MariaDB (protocol version: 10, 10.3.34-MariaDB Server). I need to remove rows where three columns are equal. I was trying to use WITH clause but database throws error that it can’t recognize ‘WITH’, so I focused on trad…
selecting columns which are NOT of a specific type SQL
I want to select all the columns in BigQuery that are not of the type “TIMESTAMP”. I have written the query which returns such columns which is: But I am struggling to return data from only these columns in SQL, I have tried the following query which results in “Scalar subquery produced more…
SSRS display text when image column is null
I’m trying to build a SSRS report that shows player name and their photos (if there is any). How do I display a text e.g.”No image” if image column return null value (or empty)? I’ve tried to do this in SSRS report itself but no luck : Any help is appreciated. Answer Assuming you get t…
How to apply max function in a join query?
I am new to SQL Server, I have 3 tables consider an employee table empid name location 1 abc USA 2 efg UK Another table named location-table location holidaycode uk uk1 usa usa1 And also holidaytable: holiday-code date type uk1 2022-01-01 LM uk1 2022-01-01 RMC Expected result is: empid location holidaycode da…
How to update a table with a foreach without overwriting?
So i’m working on a university project but i have a problem that’s really starting to bother me. I am trying to update my database several times with different values, except that only the last value will be taken into account : they’re overwriting themselves. My code : And my SQL method is …
How to use not in / not like to compare values from different tables in SQL
I have SQL 2019 with these two tables – Orders and Customers with respective columns in Orders and in Customers. Order_comment is ntext type. I need to update the order_comment with customer_name value. The update should be something like this: If the customer_name is already part of the order_comment t…