Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
Author |
Topic |
mgreen84
Yak Posting Veteran
94 Posts |
Posted - 2015-01-05 : 12:23:24
|
I'm trying to group the following dataset by hosp_id below, however. It's not grouping. can anyone assist? query below. The records are all the same but yet it wont groupSelect distinct hosp_id ,getdate() as cm_run_date ,etl_date as cm_thru_date ,datepart(day, etl_date) as cm_thru_day ,datepart(month, etl_date) as cm_thru_month ,datepart(year, etl_date) as cm_thru_year ,CASE WHEN DATEPART(QUARTER, etl_date) = 1 THEN '1Q '+CONVERT(VARCHAR, DATEPART(year, etl_date)) WHEN DATEPART(QUARTER, etl_date) = 2 THEN '2Q '+CONVERT(VARCHAR, DATEPART(year, etl_date)) WHEN DATEPART(QUARTER, etl_date) = 3 THEN '3Q '+CONVERT(VARCHAR, DATEPART(year, etl_date)) WHEN DATEPART(QUARTER, etl_date) = 4 THEN '4Q '+CONVERT(VARCHAR, DATEPART(year, etl_date)) END as cm_thru_quarter ,( Select a.etl_id From [rdc_CZ].[dbo].[CZ_ETL_Master] a Where a.etl_name ='HospBased_Master_Load08' ) as etl_id ,etL_source_id as etl_job_id ,getdate() as etl_date , COUNT(*) From [rdc_DM].[dbo].[dm_cm_HospBase_measure_Summary]group by hosp_id, etl_date, etl_source_idhosp_id cm_run_date cm_thru_date cm_thru_day cm_thru_month cm_thru_year cm_thru_quarter etl_id etl_job_id etl_date1 2015-01-05 2014-09-30 30 9 2014 3Q 2014 25 3269768 2015-01-051 2015-01-05 2014-09-30 30 9 2014 3Q 2014 25 3269778 2015-01-051 2015-01-05 2014-09-30 30 9 2014 3Q 2014 25 3269779 2015-01-05 1 2015-01-05 2014-09-30 30 9 2014 3Q 2014 25 3269780 2015-01-05 2 2015-01-05 2014-09-30 30 9 2014 3Q 2014 25 3269770 2015-01-052 2015-01-05 2014-09-30 30 9 2014 3Q 2014 25 3269787 2015-01-052 2015-01-05 2014-09-30 30 9 2014 3Q 2014 25 3269788 2015-01-052 2015-01-05 2014-09-30 30 9 2014 3Q 2014 25 3269789 2015-01-052 2015-01-05 2014-09-30 30 9 2014 3Q 2014 25 3269790 2015-01-05 3 2015-01-05 2014-09-30 30 9 2014 3Q 2014 25 3269807 2015-01-053 2015-01-05 2014-09-30 30 9 2014 3Q 2014 25 3269808 2015-01-05 4 2015-01-05 2014-09-30 30 9 2014 3Q 2014 25 3269814 2015-01-05 |
|
gbritton
Master Smack Fu Yak Hacker
2780 Posts |
Posted - 2015-01-05 : 12:39:27
|
well, the rows are not all the same are they? In fact, the etl_job_id column is different in each row. |
|
|
mgreen84
Yak Posting Veteran
94 Posts |
Posted - 2015-01-05 : 13:41:34
|
well, I feel silly. I looked and looked at those records and didn't even realize those were different smh. Thanks for the extra set of eyes.quote: Originally posted by gbritton well, the rows are not all the same are they? In fact, the etl_job_id column is different in each row.
|
|
|
|
|
|
|
|