I need to count consecutive days in order to define my cohorts. I have a table that looks like: pat_id admin_date —————————- 1 3/10/2019 1 3/11/…
Time difference between rows
In a mysql database (ver.5.7.15) I’ve got the following table named operation_list containing the following data: id (autoincrement integer, primary key), operation_date_time (datetime), operation (…
EDATE comparable in SQL Server? — Next Anniversary Date Calculation
Can someone help me figure out a formula to be used in SQL Server similar to the Excel formula pasted below? =EDATE(date,(DATEDIF(date,TODAY(),”y”)+1)*12) I want to capture the next anniversary date….
Count of files received in the last 30 days split by each day
I am trying to get a count of the number of files my company has received in the past month split up by each day. The example below shows what I want the output to look like. | Date- | | -Received- |…
How can I make all values of one identifier the same based a on value in a row?
SELECT a.IDENTIFIER, a.NAME, a.CATEGORY, b.IDENTIFIER_TYPE, b.NAME, CASE WHEN b.IDENTIFIER_TYPE = 111 THEN ‘PRESENT’ ELSE ‘NOT PRESENT’ END AS HAS111 FROM …
How to put Case in Where Statement for Oracle SQL
For the query below, I’m trying to pull a specific date range depending on the current day of the month. If it’s the 20th or less (e.g. “2/7/2020”) then I want the date range for January. Otherwise, I …
How to use aggregate functions in SQL Server
I have a situation where I have a Customer table and I need to locate document numbers from a column which is structured as a string where the first 4 characters represent the type of document (e.g.,’…
How can I query the list of IDs with conditions on couple of fields?
I have the following two tables: Table A ID Code1 Code2 ————– 1 2000 1 2 3000 2 3 1000 3 4 2100 1 5 3500 5 Table B Code1 Code2 ———– 2100 7 2100 1 3000 2 1000 4 I need to …
How can I return desired record when using pivot
I am using a pivot table to return records that have been updated in the past 7 days. If account has been updated, only return contype ‘AAA’ and ‘BBB’ for the ID. Each ID can have up to 8 ‘types’. I …
Is insert.addBatch() accessible outside of this for loop?
I have multiple for loops where I am setting the values to be inserted into a MySQL DB. My question is will insert.addBatch(); detect the insert values if it is outside of the for loop. Below is an …