I have been trying to build below logic Declare @OT float Declare @Remark varchar(100) set @OT = 9.52 set @Remark = ‘1-25 hours’ select case when @Remark=’1-25 hours’ then (FLOOR((@OT * 100)/100)*…
Tag: sql
How to delete row contain specific string on it in SQL Server
There are lots of rows that contain ’08:28:00.000′ in my table,like this one: I want to delete all the rows that ‘datetime’ contains ’08:28:00.000′.Instead of deleting this kind of rows one by one,is any command can delete all the rows than datetime contain ’08:28:00.…
ORA-01417: a table may be outer joined to at most one other table
I have this query below for oracle sql: When i execute it, i got ORA-01417: a table may be outer joined to at most one other table. Need help for this error. Answer Please use below query. In the current query, your aggregation is incorrect, you have to use same function as you use in the select query. And ch…
SQL query to add the state value dynamically
The below query returns value such as – ‘GA’,’CA’,’AL’ Query#1 (SELECT Upper(hzg.geography_name) FROM hz_geographies HZG, hz_geography_identifiers HZGI, …
JDBC connection from Databricks to SQL server
I have a scenario where I need to trigger Stored procedure in the SQL server from Databricks. With the spark SQL connector,I can able to SELECT but not trigger the stored procedure. I am trying to …
How to joins in oracle based on condition
I have two tables as below: Table Apple: Table KEEY: Desired Output: Code Tried So far: This is giving me : I guess i need to use pivot instead of Union to get both the ids on same row. Have you ever encountered such scenarios? Any pointers to proceed will be very helpful. Thanks in Advance! DDL used for the
Update column in Oracle table with value from another table with duplicates
I am trying to update the column (REPT_IND) from table A to the value in table B where A.ID = B.ID and some conditions in table B. There are some duplicates in table B, but nonetheless the REPT_IND is …
SQL count distinct # of calls 6 months prior to create date
Am trying to figure out the SQL to: count # of distinct calls made on an account 6 months prior to the account being created I also need to CAST the date field. I’m thinking something like: case …
Depending on column value, query different tables
I have table A where each IDENTIFIER value is unique. Depending on whether its CC or DC, I need to join it with different tables, for example if its “CC_” I need to map it to table B and if its “DC_” I need to map it to table C. TABLE A: TABLE B: TABLE C: I want the result
Insert query with a column that is the total number of records from another table
I have a query that inserts data from another table, into an empty table (the table is cleared once a day, and new data is put in once a day). Currently it looks like this: INSERT INTO new (…