Skip to content
Advertisement

Tag: subquery

SELECT NOT IN with multiple columns in subquery

Regarding the statement below, sltrxid can exist as both ardoccrid and ardocdbid. I’m wanting to know how to include both in the NOT IN subquery. Answer I would recommend not exists: Note that I changed the table aliases to things that are more meaningful. I would strongly recommend prefixing the column names with the table they belong to, so the

Oracle – Count based on previous and next column

I’ve got a rather unusual question about some database query with oracle. I got asked if it’s possible to get the number of cases where the patient got a resumption on the same station they were discharged from within 48 / 72 hours. Consider the following example: Case Station From To 1 Stat_1 2020-01-03 20:10:00 2020-01-04 17:40:00 1 Stat_2 2020-01-04

Query help in SQL

I have the below table, with empid, deptid, and Name. I need to get the results as empid,deptid,name and count of employees in each department. I need to get the results as empid,deptid,name, and count of employees in each department as below. I am able to achieve results using the below queries. Is it possible to do this in alternate

Advertisement