select "T0"."C0" AS "Vendor_Name", "T0"."C1" AS "Feature_Name", "T0"."C2" AS "Date1", "T0"."C3" AS "Date4", "T0"."C4" AS "Server_Host_Name", "T0"."C5" AS "Month_Num", "T0"."C6" AS "Peak_Licenses", "T0"."C7" AS "Ultimate_Denials", "T0"."C8" AS "Availability_Count", "T0"."C9" AS "Total_Time_Used__hours_", "T0"."C8" AS "Availability_Count1", "T0"."C10" AS "User_Name", "T0"."C11" AS "First_Name", "T0"."C12" AS "Last_Name", "T0"."C13" AS "E_mail", "T0"."C14" AS "City", "T0"."C15" AS "State_Province", "T0"."C16" AS "Country", "T0"."C17" AS "Day_of_Month", "T0"."C18" AS "Department", "T0"."C19" AS "Data_Item2" from ( select "RPTVW_FEATURE_VENDOR_LS_DAY"."VENDOR_NAME" AS "C0", "RPTVW_FEATURE_VENDOR_LS_DAY"."FEATURE_NAME" AS "C1", cast("RPTVW_FEATURE_VENDOR_LS_DAY"."DATE_ACTUAL" as date) AS "C2", "RPTVW_FEATURE_VENDOR_LS_DAY"."DATE_ACTUAL" AS "C3", "RPTVW_FEATURE_VENDOR_LS_DAY"."SERVER_HOST_NAME" AS "C4", "RPTVW_FEATURE_VENDOR_LS_DAY"."MONTH_NUM" AS "C5", max("RPTDW_DAILY_MEASURE_LEAF"."MAX_USED_AT_PEAK_COUNT") AS "C6", sum("RPTDW_DAILY_MEASURE_LEAF"."ULTIMATE_DENIAL_COUNT") AS "C7", max(case when "RPTDW_DAILY_AVAILABILITY"."AVAILABILITY" < 1000000000 then "RPTDW_DAILY_AVAILABILITY"."AVAILABILITY" else NULL end ) AS "C8", sum(CAST( "RPTDW_DAILY_MEASURE_LEAF"."TOTAL_USED_TIME" AS DOUBLE PRECISION ) / 3600) AS "C9", "RPTDW_USER"."NAME" AS "C10", "RPTDW_USER"."FIRST_NAME" AS "C11", "RPTDW_USER"."LAST_NAME" AS "C12", "RPTDW_USER"."EMAIL" AS "C13", "RPTDW_USER"."CITY" AS "C14", "RPTDW_USER"."STATE_PROVINCE" AS "C15", "RPTDW_USER"."COUNTRY" AS "C16", "RPTVW_FEATURE_VENDOR_LS_DAY"."DAY_OF_MONTH" AS "C17", "RPTDW_USER"."DEPARTMENT" AS "C18", substring("RPTDW_USER"."CUSTOM2",4,charindex(N',OU',"RPTDW_USER"."CUSTOM2") - 4) AS "C19" from (( select "RPTDW_DIM_TIME"."ID" AS "TIME_ID", "RPTDW_DIM_TIME"."MONTH" AS "MONTH_NUM", "RPTDW_DIM_TIME"."DAY_OF_MONTH", "RPTDW_DIM_TIME"."DATE_ACTUAL", "RPTDW_FEATURE"."ID" AS "FEATURE_ID", "RPTDW_FEATURE"."NAME" AS "FEATURE_NAME", "RPTDW_SERVER_HOST"."ID" AS "SERVER_HOST_ID", "RPTDW_SERVER_HOST"."HOST_NAME" AS "SERVER_HOST_NAME", "RPTDW_VENDOR"."VENDOR_NAME" from "RPTDW_SERVER_HOST" "RPTDW_SERVER_HOST", "RPTDW_VENDOR" "RPTDW_VENDOR", "RPTDW_DIM_TIME" "RPTDW_DIM_TIME", "RPTDW_FEATURE" "RPTDW_FEATURE" where "RPTDW_VENDOR"."ID" = "RPTDW_FEATURE"."VENDOR_ID" and "RPTDW_DIM_TIME"."HOUR_OF_DAY" = 0) "RPTVW_FEATURE_VENDOR_LS_DAY" LEFT OUTER JOIN ("RPTDW_USER" "RPTDW_USER" INNER JOIN "RPTDW_DAILY_MEASURE_LEAF" "RPTDW_DAILY_MEASURE_LEAF" on "RPTDW_USER"."ID" = "RPTDW_DAILY_MEASURE_LEAF"."USER_ID") on "RPTVW_FEATURE_VENDOR_LS_DAY"."FEATURE_ID" = "RPTDW_DAILY_MEASURE_LEAF"."FEATURE_ID" and "RPTVW_FEATURE_VENDOR_LS_DAY"."SERVER_HOST_ID" = "RPTDW_DAILY_MEASURE_LEAF"."SERVER_HOST_ID" and "RPTVW_FEATURE_VENDOR_LS_DAY"."TIME_ID" = "RPTDW_DAILY_MEASURE_LEAF"."TIME_ID") LEFT OUTER JOIN "RPTDW_DAILY_AVAILABILITY" "RPTDW_DAILY_AVAILABILITY" on "RPTVW_FEATURE_VENDOR_LS_DAY"."SERVER_HOST_ID" = "RPTDW_DAILY_AVAILABILITY"."SERVER_HOST_ID" and "RPTVW_FEATURE_VENDOR_LS_DAY"."TIME_ID" = "RPTDW_DAILY_AVAILABILITY"."TIME_ID" and "RPTVW_FEATURE_VENDOR_LS_DAY"."FEATURE_ID" = "RPTDW_DAILY_AVAILABILITY"."FEATURE_ID" where "RPTDW_DAILY_MEASURE_LEAF"."MAX_USED_AT_PEAK_COUNT" > 0 group by "RPTVW_FEATURE_VENDOR_LS_DAY"."VENDOR_NAME", "RPTVW_FEATURE_VENDOR_LS_DAY"."FEATURE_NAME", cast("RPTVW_FEATURE_VENDOR_LS_DAY"."DATE_ACTUAL" as date), "RPTVW_FEATURE_VENDOR_LS_DAY"."DATE_ACTUAL", "RPTVW_FEATURE_VENDOR_LS_DAY"."SERVER_HOST_NAME", "RPTVW_FEATURE_VENDOR_LS_DAY"."MONTH_NUM", "RPTDW_USER"."NAME", "RPTDW_USER"."FIRST_NAME", "RPTDW_USER"."LAST_NAME", "RPTDW_USER"."EMAIL", "RPTDW_USER"."CITY", "RPTDW_USER"."STATE_PROVINCE", "RPTDW_USER"."COUNTRY", "RPTVW_FEATURE_VENDOR_LS_DAY"."DAY_OF_MONTH", "RPTDW_USER"."DEPARTMENT", substring("RPTDW_USER"."CUSTOM2",4,charindex(N',OU',"RPTDW_USER"."CUSTOM2") - 4)) "T0"