Viewing 15 posts - 1 through 15 (of 388 total)
Got it to work with some CTE acrobatics:
WITH First_CTE AS (
SELECT DISTINCT
clm.pat_id, ...
September 6, 2024 at 7:02 pm
I have another pesky string_agg for which I'm trying to follow the example above but not getting the results like a field that has the aggregate like: "All, MH":
September 6, 2024 at 3:02 pm
Thx! I prefer, for now, to look for a subquery since my *real* SQL already has one CTE (I've used 20+ before). I should not have oversimplified my code, but...
December 19, 2023 at 5:20 pm
It's varchar(15). Casting as varchar(max) was the seemingly only way to avoid this error:
"STRING_AGG aggregation result exceeded the limit of 8000 bytes. Use LOB types to avoid result truncation."
December 19, 2023 at 3:30 pm
That works until I try to add additional fields to be returned:
select distinct
i.ins_num
from dbo.tb_pat_ins i
where i.active = 1
...
July 17, 2023 at 1:01 pm
I thought it best to add onto an existing thread since the issue is very similar with a new challenge. I need to return all the insurance numbers that have...
July 13, 2023 at 6:59 pm
I found this to work perfectly:
where ServiceDate between DATEADD (mm, DATEDIFF (mm, 0, GETDATE ()) - 1, 0) and
dateadd (dd, -1, DATEADD...
February 21, 2023 at 7:13 pm
I tried this code and it's not perfect but works, but I'm sure there's a better way:
declare @StartDate DATETIME, @EndDate DATETIME
SET @StartDate = dateadd(mm, -1, getdate())
SET @StartDate...
February 20, 2023 at 4:24 pm
I need for the person's name to be unique. So one of the records for 'Reece, Genais' needs to be eliminated. It doesn't matter which one:
Solved: Removing the 'DISTINCT' from the very first line made the query run much faster.
August 10, 2022 at 2:50 pm
I have the query bringing back good data but for just 5,204 records it is taking over 10 minutes. The SQL I shared for solving the problem with the MAX...
August 9, 2022 at 8:04 pm
Thanks!! I got it to work using cross apply.
August 9, 2022 at 6:23 pm
I need all the patient ids returned but no duplicates, only the record that has the highest ProcedureCodeId.
August 9, 2022 at 1:35 pm
Should I be placing my Cross Apply within the CTE in place of MAX or place it in the selection at the bottom?
August 9, 2022 at 1:30 pm
Viewing 15 posts - 1 through 15 (of 388 total)