Skip to content

Instantly share code, notes, and snippets.

@sebbacon
Created November 27, 2023 10:17
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sebbacon/4505d4092d63d7a0b5b3bd17136af9c3 to your computer and use it in GitHub Desktop.
Save sebbacon/4505d4092d63d7a0b5b3bd17136af9c3 to your computer and use it in GitHub Desktop.
select s1.d, n1, n2, cast(n2 as decimal) / cast(n1 as decimal)
from
(
select d, count(*), n1 from (
select convert(varchar(7), admission_date, 23) d
from apcs_cost c
join apcs a
on c.apcs_ident = a.apcs_ident
) s
group by d
) s1
join
(
select d, count(*), n1 from (
select convert(varchar(7), admission_date, 23) d
from apcs_cost_jrc20231009_lastfilestocontainallhistoricalcostdata c
join apcs_jrc20231009_lastfilestocontainallhistoricalcostdata a
on c.apcs_ident = a.apcs_ident
) s
group by d
) s2
on s1.d = s2.d
order by d
@Jongmassey
Copy link

Where's n2 coming from, or should L14 read n2 instead of n1?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment