Improve company productivity with a Business Account.Sign Up

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 42
  • Last Modified:

SSRS Grouping Problem

Hi,
      I am developing a SSRS Report, which is based on three tables,  Orders , invoice and receipts

the relation between orders and receipts is one to many
the relation between orders and invoice is one to many

and there is no relation between invoice and receipts

I am using left join between these tables to get data.

In my report there are columns related to all 3 tables,


My requirement is date wise filtration of all records , i.e.  if order date is not in between search dates it should not display but if receipts or invoice exists it should be shown.

please find the attachment for sample data and report format. Sample.xlsx
0
codeoxygen
Asked:
codeoxygen
1 Solution
 
Bob LearnedCommented:
What is the problem that you are having with grouping?
0
 
Jim HornMicrosoft SQL Server Developer, Architect, and AuthorCommented:
The attached spreadsheet doesn't make any sense, and the question isn't real clear either, so I'll answer this way..

Most SSRS reports will have as a data source a Stored Procedure, which can accept parameters.

So ... Create a Stored procedure that populates your report, with two parameters for begin date and end date.
Test it to make sure that the return set is 'filtered' based on those dates.

Then in SSRS open the data source, set it to the Stored Procedure, and make sure the parameters are set correctly.
When finished, when a user runs the report, they will be prompted for those two parameters.  When values are entered and the 'Run Report' button is clicked, those values will be fed into the Stored Procedure as parameters, return a set that's filtered by them.
0
 
codeoxygenAuthor Commented:
my problem is , when order table is joined with receipts table....

Example : Order is raised on 9th feb , for that respective order receipt is raised on 10th feb and invoice is raised on 11th feb.

In my query i am joining as

Select * from  Order O
left join receipts R on R.orderid=O.orderid
Left join Invoice I on I.orderid=O.orderid


here , if i search with from and to  Date= 9th feb date
only order information need to come

if serch with from date = 9th feb and To Date=10th feb

then  order and its receipt should display, that to in different rows.

if search with from date = 9th feb and To Date=11th feb

then  order ,Invoice and its receipt should display, that to in different rows.


this is the condition but if want get receipts details order details will come automatically in query as it is joined based on order, How to hide those order details if they are not in between search date
0
 
nishant joshiTechnology Development ConsultantCommented:
Hello Author,

You can use below code for reference.You need to create one date list which is based on provided data in parameter.

Using that as reference value you can join your order table and it's date to get desire output.

DECLARE 
	@FromDate DATE = GETDATE() - 5,
	@ToDate DATE = GETDATE()

;WITH Dates
AS
(
SELECT @FromDate AS DateList
UNION ALL
SELECT DATEADD(DD,1,Datelist) AS Datelist
FROM Dates
WHERE DateList < @ToDate
)
SELECT *
FROM Dates
INNER JOIN Order O ON o.OrderDate BETWEEN Dates.DateList AND Dates.DateList + 1
left join receipts R on R.orderid=O.orderid
Left join Invoice I on I.orderid=O.orderid

Open in new window

0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now