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.

 All Forums
 Development Tools
 Reporting Services Development
 Difficult JOIN with NULL values for Reporting Serv

Author  Topic 

jtrapat1
Starting Member

43 Posts

Posted - 2008-09-07 : 16:28:26
Im having a tough time refreshing the drop down values of my Reporting Services parameter box;
I think the problem is more on the type of join in the sql rather than the reporting services IDE, but Ill post it here;
Basically, this is a calendar application which takes multiple stored procedures to refresh the parameter boxes on the reports screen;
The first two parameters are a start and end date-
these refresh the dropdown on the next line which is populated with a Client name (and id selected in the sql)
Next I am passing this start and end date and clientid to get the available values for this clientid from two tables: Reservations AND Events. (The Events table is actually a view.)
My Start Date and End Date are OK and Im trying to pass to the second stored procedure to get All of the Clients (with IDs) who have reservations OR events in that Date Range-
Hers my query so far -
But, Im not getting all of the events and/or Reservations for the specific clientid;
-------------------------
SELECT DISTINCT R.[General/EventID], E.[EventName] --, R.[General/ClientID]
FROM Reservations R
LEFT OUTER JOIN
[vw_Events] E
ON E.[EventID]=R.[General/EventID]
where R.[General/EventID] is not null and E.[EventName] is not null
and (R.[General/ClientID]=@clientID)
AND (CONVERT(VARCHAR(10),R.[actual end],101) >= @startdate)
AND (CONVERT(VARCHAR(10),R.[actual end],101) <= @enddate)
------------------------
So, in the case where General/EventID is NULL for certain values, I don't get returned the three records for this ClientID from the Reservations table.
Is there something I could do differently to get all of the records in these two tables for this client regardless, And not show NULL in the drop down?

Thanks
Please Help.
John

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2008-09-13 : 13:58:02
quote:
Originally posted by jtrapat1

Im having a tough time refreshing the drop down values of my Reporting Services parameter box;
I think the problem is more on the type of join in the sql rather than the reporting services IDE, but Ill post it here;
Basically, this is a calendar application which takes multiple stored procedures to refresh the parameter boxes on the reports screen;
The first two parameters are a start and end date-
these refresh the dropdown on the next line which is populated with a Client name (and id selected in the sql)
Next I am passing this start and end date and clientid to get the available values for this clientid from two tables: Reservations AND Events. (The Events table is actually a view.)
My Start Date and End Date are OK and Im trying to pass to the second stored procedure to get All of the Clients (with IDs) who have reservations OR events in that Date Range-
Hers my query so far -
But, Im not getting all of the events and/or Reservations for the specific clientid;
-------------------------
SELECT DISTINCT R.[General/EventID], E.[EventName] --, R.[General/ClientID]
FROM Reservations R
LEFT OUTER JOIN
[vw_Events] E
ON E.[EventID]=R.[General/EventID]
where R.[General/EventID] is not null and E.[EventName] is not null
and (R.[General/ClientID]=@clientID)
AND (CONVERT(VARCHAR(10),R.[actual end],101) >= @startdate)
AND (CONVERT(VARCHAR(10),R.[actual end],101) <= @enddate)
------------------------
So, in the case where General/EventID is NULL for certain values, I don't get returned the three records for this ClientID from the Reservations table.
Is there something I could do differently to get all of the records in these two tables for this client regardless, And not show NULL in the drop down?

Thanks
Please Help.
John



In the code in blue above you're checking for records with General/EventID NOT NULL. so this will ignore all records with null values for this field. I think you're looking for something like below

SELECT DISTINCT R.[General/EventID], E.[EventName] --, R.[General/ClientID]  
FROM Reservations R
LEFT OUTER JOIN
[vw_Events] E
ON E.[EventID]=R.[General/EventID]
where (R.[General/EventID] is not null or E.[EventName] is not null)
and (R.[General/ClientID]=@clientID)
AND (CONVERT(VARCHAR(10),R.[actual end],101) >= @startdate)
AND (CONVERT(VARCHAR(10),R.[actual end],101) <= @enddate)


and do the filter in reporting services to exclude null values in dropdown.
Go to Top of Page

jtrapat1
Starting Member

43 Posts

Posted - 2008-09-15 : 11:50:20
visakh16,
Thanks for the response-
You were absolutely right on this error-

The NULL values problem is very confusing to me.

Thanks Again.
John
Go to Top of Page

SwePeso
Patron Saint of Lost Yaks

30421 Posts

Posted - 2008-09-15 : 11:59:48
[code]SELECT DISTINCT r.[General/EventID],
e.[EventName]
FROM Reservations AS r
LEFT JOIN [vw_Events] AS e ON e.[EventID] = r.[General/EventID]
WHERE r.[General/ClientID] = @clientID
AND r.[actual end] >= @startdate
AND r.[actual end] < DATEADD(DAY, 1, @enddate)[/code]


E 12°55'05.63"
N 56°04'39.26"
Go to Top of Page
   

- Advertisement -