Skip to content

Tag: sql-server

Sum By Criteria in specific column

I have questions about SQL Server query for SUM. I have 2 tables: 1) EmployeesAtt (EId, EName, Stats) -> I have some criteria for Stats (0 = late, 1 = overtime, 2 = normal) 2) AttLogs (ID, EId, late, overtime, normal) From EmployeesAtt table, I want to SUM the EId And Stats in dedicated column in AttLogs l…

T-SQL, looking to extract drug dose from column

I have a column of drug names with dose and I’m trying to extract the just the dose from the field. The difficulty comes in when I have combination drugs that have multiple doses. I can either extract the first numbers in the string, or all of them in one string with no way to separate them. Desired out…

SQL – find all combinations

From a dataset like this, I need to get all possible combinations of cases in the same room so that no case overlaps another. The expected result is I am able to get single line results of what case can be combined with which other case like: And I’ve tried some recursions but I am at a loss nowhere nea…