SSRS: Custom parameter layout was removed from the report - reporting-services

When I add a parameter to my report, add it to the query and used it in a calculated field, running the report gives me this error:
"Custom parameter layout was removed from the report. SQL Server 2014
Reporting Services and earlier do not support custom parameter
layout."
My report runs but returns no rows, just column headers.
My parameter is of type Date/Time
My query is:
SELECT HD_QUEUE.NAME as qname, HD_TICKET.ID, HD_TICKET.CREATED, HD_TICKET.TIME_CLOSED, CUSTOMER.FULL_NAME as custfullname,
HD_STATUS.NAME as statname, HD_TICKET.TITLE, left(ASSIGNEE.FULL_NAME, 40) as assignee,
HD_PRIORITY.NAME as pname, HD_CATEGORY.NAME as catname
FROM HD_TICKET
INNER JOIN HD_QUEUE
ON HD_TICKET.HD_QUEUE_ID = HD_QUEUE.ID
INNER JOIN USER CUSTOMER
ON HD_TICKET.SUBMITTER_ID=CUSTOMER.ID
INNER JOIN USER ASSIGNEE
ON HD_TICKET.OWNER_ID=ASSIGNEE.ID
INNER JOIN HD_STATUS
ON (HD_TICKET.HD_STATUS_ID=HD_STATUS.ID)
AND (HD_TICKET.HD_QUEUE_ID=HD_STATUS.HD_QUEUE_ID)
INNER JOIN HD_PRIORITY
ON HD_TICKET.HD_PRIORITY_ID = HD_PRIORITY.ID
and HD_TICKET.HD_QUEUE_ID = HD_PRIORITY.HD_QUEUE_ID
INNER JOIN HD_CATEGORY
ON HD_TICKET.HD_CATEGORY_ID = HD_CATEGORY.ID
and HD_TICKET.HD_QUEUE_ID = HD_CATEGORY.HD_QUEUE_ID
left join ASSET on ASSET.ID = HD_TICKET.ASSET_ID
left join ASSET_DATA_6 on ASSET.ASSET_DATA_ID = ASSET_DATA_6.ID
WHERE HD_STATUS.NAME = 'Closed'
AND HD_TICKET.TIME_CLOSED > DATE_SUB(#date_param, INTERVAL 34 DAY)
AND HD_TICKET.TIME_CLOSED <= #date_param;
And my calculated field is:
=IIf(Fields!closed_date.Value > (DateAdd(DateInterval.Day, -6, Parameters!date_param.Value)), "Week 1",
IIf(Fields!closed_date.Value > (DateAdd(DateInterval.Day, -13, Parameters!date_param.Value)), "Week 2",
IIf(Fields!closed_date.Value > (DateAdd(DateInterval.Day, -20, Parameters!date_param.Value)), "Week 3",
IIf(Fields!closed_date.Value > (DateAdd(DateInterval.Day, -27, Parameters!date_param.Value)), "Week 4",
"Week 5"))))

Related

Is there a way to find the Enabled/Disabled status of a SSRS subscription?

I have been tasked to write a report that allows the entry of an email address and report all report names and its active status (Disabled or Expired) where the email address is found. I found the following query on stackoverflow, but I cannot see a column that would indicate whether or not the subscription is Disabled or Expired.
I found 1 column "enabled", but doing a SELECT DISTINCT(enabled) only produced a single return of "1".
Any suggestions on what table I need to include to be able to include the subscription status in my output?
use ReportServer
SELECT top 10 *
FROM
dbo.[Catalog] c
RIGHT OUTER JOIN dbo.[Subscriptions] S ON c.ItemID = S.Report_OID
RIGHT OUTER JOIN dbo.ReportSchedule R ON S.SubscriptionID = R.SubscriptionID
RIGHT OUTER JOIN msdb.dbo.sysjobs J ON Convert(nvarchar(128),R.ScheduleID) = J.name
RIGHT OUTER JOIN msdb.dbo.sysjobschedules JS ON J.job_id = JS.job_id
where coalesce(c.Name,' ') != ' '
order by c.Name
Found it.
Enabled: dbo.[Subscriptions].InactiveFlags = 0
Disabled: dbo.[Subscriptions].InactiveFlags = 128

mysql - IF...ELSE or CASE in ORDER BY statement

In my query below I am not getting the desired result. I want the results to sort according to the latest event occurrence based on two different date fields of two different tables. Let's see the query first.
SELECT R1.swp_to, R1.swp_type, R1.swp_date, M.mem_fname, M.mem_lname, M.mem_last_activity, DP.dp_photo, GREATEST(R1.swp_date, R2.swp_date) FROM swipes AS R1
LEFT JOIN swipes AS R2 ON(R1.swp_to = R2.swp_by AND R2.swp_to = R1.swp_by AND R2.swp_type <> 'left')
LEFT JOIN members AS M ON(R1.swp_to = M.mem_id)
LEFT JOIN display_photos AS DP ON(R1.swp_to = DP.dp_mem AND DP.dp_index = 1)
LEFT JOIN messages as MSG ON ((R1.swp_to = MSG.msg_from OR R1.swp_to = MSG.msg_to) AND (R1.swp_by = MSG.msg_from OR R1.swp_by = MSG.msg_to))
WHERE R1.swp_by = :mem AND R2.swp_by IS NOT NULL AND R1.swp_type <> 'left'
ORDER BY IF(MSG.msg_time IS NULL, 0, 1), R1.swp_date
Here in the ORDER BY statement we can see that there are two TIME fields msg_time and swp_date. Whenever there is a new match swp_date updates and when there is a new message msg_time updates. The records fetched using this query must be sorted as per the latest event occurrence (whichever date is the earliest of the two). My current ORDER BY statements does not fulfill the requirement. What am I missing here?
You can use the function GREATEST():
ORDER BY GREATEST(COALESCE(MSG.msg_time, R1.swp_date), R1.swp_date) DESC

Group By causing bug after Database restore

I am working on a rather complex and time critical data conversion.
This is achieved by using a Stored Procedure.
A recent change request required me to update this stored procedure. To do so in a safe manner, I have created a full schema dump including data and have imported this into two different schemas. One called 'original' and one called 'amended'.
Before updating the live database I am trying to compare the output of the original and amended database to identify the data that has been added and that none has been lost.
Unfortunately my test system is running MySQL v 5.7.12-0ubuntu-1 whereas my live server is a CentOS Server running 5.6.30.
A group clause in the original database (identical with live) is raising an issue (that does not exist on live). This error (1055 - Expression #5 of SELECT list is not in GROUP BY clause and contains non-aggregated column) makes total sense and is addressed in the revised database. I just want to run a comparison without having to install the exact same version of MySQL on this development server.
I have tried to remove ONLY_FULL_GROUP_BY from my sql_mode parameter and have matched the sql_mode on both servers to only NO_ENGINE_SUBSTITUTION
Can anyone help? The query is below:
Insert into skeleton_football (
sport_id,
parent_event_id,
event_id,
event_part_id,
back_outcome_id,
lay_outcome_id,
start_time,
market_type,
competition_name,
event_name,
event_part_name,
outcome_name,
outcome_value
)
SELECT
sp.id as `sport_id`,
if (ev.name is null, pev.id, null) as `parent_event_id`,
ev.id as `event_id`,
evp.id as `event_part_id`,
oc.back_outcome_id as back_outcome_id,
oc.lay_outcome_id as lay_outcome_id,
#oc.param_float_1,
#oc.param_float_2,
#oc.param_float_3,
#oc.param_boolean_1,
#oc.param_string_1,
#oc.param_participant_id_1,
#oc.param_participant_id_2,
#oc.param_participant_id_3,
#oc.param_event_part_id_1,
ev.start_time as start_time,
sp.name as market_type,
if (ev.name is null, pev.name, ev.name) as competition_name,
if (sp.name = "football",concat(epah.name, " v ", epaa.name),ev.name) as event_name,
evp.name as event_part_name,
oct.name as outcome_name,
get_outcome_value(
oct.name,
oc.param_participant_id_1,
max(epah.id),
max(epah.name),
max(epaa.id),
max(epaa.name),
opa.id,
opa.name,
oc.param_float_1,
oc.param_float_2,
oc.param_boolean_1
) as outcome_value
FROM raw_event ev
left join raw_event pev on pev.id = ev.parent_id
inner join raw_sport sp on ev.sport_id = sp.id
inner join config_events_filter cef on cef.sport_id = sp.id and (cef.competition_name is null or pev.name like cef.competition_name)
left join outcome_matched oc on ev.id = oc.event_id
inner join raw_event_part evp on evp.id = oc.event_part_id and evp.name in ("ordinary time", "whole match", "whole event")
cross join raw_participant_role prh on prh.name ="home"
cross join raw_participant_role pra on pra.name = "away"
cross join raw_participant_role pro on pro.name not in ("home", "away")
left join raw_event_participant_relation pera on pera.event_id = ev.id and pra.id = pera.participant_role_id
left join raw_event_participant_relation perh on perh.event_id = ev.id and prh.id = perh.participant_role_id
left join raw_event_participant_relation pero on pero.event_id = ev.id and pro.id = pero.participant_role_id
left join raw_outcome_type oct on oc.type_id = oct.id
left join raw_participant epaa on pera.participant_id = epaa.id
left join raw_participant epah on perh.participant_id = epah.id
left join raw_participant epao on pero.participant_id = epao.id
#left join raw_participant epap on per.participant_id = epap.id and pr.name not in ("home", "away")
left join raw_participant opa on oc.param_participant_id_1 = opa.id
where ev.start_time > date_sub('2016-05-11 14:00:00', INTERVAL 1 HOUR)
and ev.start_time < date_add('2016-05-11 14:00:00', INTERVAL 2 DAY)
group by sp.id, ev.id, evp.id, oc.back_unique, if (sp.name = "football",concat(epah.name, " v ", epaa.name),ev.name)
having event_name is not null;

How to filter on Access Report subtotal

Have an access report that shows training programs, and which employees should be but are not trained on that program. This query is fine. Problem is that we want to only display on the report training programs which have more than 10 employees untrained. So we have the total of untrained for each program in a subtotal, but we want to filter on that value.
How can this be done?
EDIT:
Here is pass-through query to SQL Server
SELECT T.ProgramTitle
,T.ProgramCode
,AE.Code AS 'AvantiCode'
,AE.FullName
,AE.FirstName
,AE.LastName
,AE.Department
,C.Position
,AE.Shift
FROM HR_Curriculum C
INNER JOIN HR_Trainings T ON C.TrainingID = T.TrainingID
INNER JOIN HR_EmployeeDetails ED ON C.Position = ED.Postion
INNER JOIN Avanti_Employees AE ON ED.AvantiRecID = AE.RecID
LEFT JOIN HR_Employeetrainings ET ON C.TrainingID = ET.TrainingID
AND ED.AvantiRecID = ET.AvantiRecID
LEFT JOIN HR_TrainingVersion V ON V.VersionID = ET.VersionID
WHERE terminated = 0
AND T.Active = - 1
AND CompletedDate IS NULL
GROUP BY T.ProgramTitle
,T.ProgramCode
,AE.Code
,AE.FullName
,AE.FirstName
,AE.LastName
,AE.Department
,C.Position
,AE.Shift
Order by programtitle
Consider an inline view, using a grouped by table alias with HAVING clause.
Try adding one more inner join:
INNER JOIN
(SELECT TrainingID, ProgramTitle, ProgramCode
FROM HR_Trainings
GROUP BY TrainingID, ProgramTitle, ProgramCode
HAVING Count(TrainingID) > 10) AS Trainings10More
ON Trainings10More.TrainingID = T.TrainingID

Use same column in a SQL Query twice

I'm writing sql query where I want to use the same column twice in datagrid view.
Here is my query:
SELECT ElectricityMachinePanelDetails.MachineDescription AS "Machine Name",
ReadingValue AS "Last Day Meter Reading"
FROM ElectricityDailyMeterReadingDetails
INNER JOIN ElectricityMachinePanelDetails ON ElectricityMachinePanelDetails.MachinePanelID = ElectricityDailyMeterReadingDetails.MachinePanelID
INNER JOIN ReadingTypesDetails ON ElectricityDailyMeterReadingDetails.ReadingTypeID = ReadingTypesDetails.ReadingTypeID
WHERE ReadingCategoryID = 'RC001' AND
ReadingTypesDetails.ReadingTypeID = 'RT001'
How can I use column name ReadingValue twice in the datagrid.
First of all, use aliases instead of table names in joins. So your query could be more readable.
select
empd.MachineDescription as "Machine Name",
rtd.ReadingValue AS "Last Day Meter Reading"
from ElectricityDailyMeterReadingDetails as edmrd
inner join ElectricityMachinePanelDetails as empd on empd.MachinePanelID = edmrd.MachinePanelID
inner join ReadingTypesDetails as rtd on rtd.ReadingTypeID = edmrd.ReadingTypeID
where
rtd.ReadingCategoryID = 'RC001' and
rtd.ReadingTypesDetails.ReadingTypeID = 'RT001'
If you want to join ReadingTypesDetails twice, you can easily do this:
select
empd.MachineDescription as "Machine Name",
rtd.ReadingValue as "Last Day Meter Reading",
rtd2.ReadingValue as "Another Reading"
from ElectricityDailyMeterReadingDetails as edmrd
inner join ElectricityMachinePanelDetails as empd on empd.MachinePanelID = edmrd.MachinePanelID
inner join ReadingTypesDetails as rtd on rtd.ReadingTypeID = edmrd.ReadingTypeID
inner join ReadingTypesDetails as rtd2 on rtd2.ReadingTypeID = edmrd.ReadingTypeID
where
rtd.ReadingCategoryID = 'RC001' and
rtd.ReadingTypesDetails.ReadingTypeID = 'RT001' and
--rtd2.ReadingCategoryID = '????' and
--rtd2.ReadingTypesDetails.ReadingTypeID = '????' and
You could just use it twice, if the datagridview allows doublename im not sure. Otherwise just give it another name "Last Day Meter Reading Copy".
Select
ElectricityMachinePanelDetails.MachineDescription AS "Machine Name",
ReadingValue AS "Last Day Meter Reading",
ReadingValue AS "Last Day Meter Copy"
from ElectricityDailyMeterReadingDetails
INNER JOIN ElectricityMachinePanelDetails on ElectricityMachinePanelDetails.MachinePanelID = ElectricityDailyMeterReadingDetails.MachinePanelID
INNER JOIN ReadingTypesDetails ON ElectricityDailyMeterReadingDetails.ReadingTypeID = ReadingTypesDetails.ReadingTypeID where ReadingCategoryID = 'RC001' AND ReadingTypesDetails.ReadingTypeID = 'RT001'
In MSSQL you cannot have the same column name twice i think. But in MySQL its fine.