so i need this to write in oracles sql using sysdate sum(datediff(day,Clan.Dat_od,(CASE when clan.dat_do is null then getdate() else clan.dat_do end ))) as brojdana
SQL query does not return correct results
I am trying to filter between two dates on a SQL server from a PHP process. This is the query: select * from webStocks where FECHAMODIFICADO between ‘2020-06-03 17:16:02’ and ‘2020-06-04 17:16:03’ …
GBQ SQL: For each unique value in Column A, if value ‘X’ appears in Column B….then create new Column C with value ‘Y’, else ‘N’
I’m using Google Big Query Standard SQL. Trying to figure out how to write this code. I have this table. A B 1 20 1 20 1 10 2 20 2 30 For each unique value in Column A, if the Column B …
How to query rows depending on multiple to-many properties?
I have one-to-many relation between tables user and tag: Users: id username ————– 1 Bob 2 Alice 3 Eve Tags: id user_id name ——————– 1 1 …
SQL Server : each month for the rows and the years for the columns
I am a trying to neatly separate data by year, I have the following query that accomplishes this, however, the date column (YYYYMM) shows every month of every year. So each annual column is zeros for …
Referencing a column in an SQLite case statement
I have an SQLite table called table. It has 4 columns: col_1, col_2, col_3, col_4. If I was to use MySQL as a way of explaining what I want to do, it is something like this: SELECT CASE WHEN col_4 …
Select specific number of sub items
I have this collection of data that I made a query on it Hotel_Id | User_Id | Comment | Date 1 1 Hello world 2020-1-1 1 2 Hello world 2020-1-1 1 …
SQL: Getting previous record from other table
I want to get the previous record of each record in Table A from Table B. for easy, below is the table sample data: drop table if exists #A drop table if exists #B CREATE TABLE #A(Name varchar(10), …
How to split a column into multiple columns by condition delimeter in SQL?
could anyone help me please? I have this column Column John > Doe Doe > Writer Jane > Doe > Chemical Engineer > Sovena I want to my final result to be …
SQL case return more than 1 row write a string
I have a subquery in SELECT and sometimes it returns more than one row. I want to solve the problem like this: when more than 1 row write a string like ‘multi’ otherwise use the value description …