Monday, February 20, 2012

Report selection formula

this does not show actual code, I have simplified it to post here.

I have linked two tables in my report

MasterTable
ID : Person Name

DetailTable
ID : workDone

and using a selection formula
{MasterTable.ID} > 1

Fields In report are being displayed.

ID | PersonName | WorkDone

the problem is if Detail Table does not have any related record. Report does not show any thing at all. I expect to view ID and PersonName fields with WorkDone field empty.

can any body help. Thanks a lotIf you use a JOIN or RIGHT JOIN to link the 2 tables together, it will only return a row from the first table (MasterTable ) if there's a match in the second table (DetailTable). If youchange it to a LEFT JOIN, it will return all rows from both Tables.

Ex.

Master Table Rows:
ID | PersonName
-----
01 | Bob
02 | Joe
03 | Bill

DetailTable Rows:
ID | WorkDone
----
01 | Data1
03 | Data3

SELECT M.ID, M.PersonName, D.WorkDone
FROM MasterTable As M
LEFT JOIN DetailTable As D ON M.ID = D.ID

will give you this:

Results:
ID | PersonName | WorkDone
--------
01 | Bob | Data1
02 | Joe | NULL <-- Returns a NULL if there is no matching row in DetailTable
03 | Bill | Data3|||Thanks a lot Malleyo

You are right about SQL part but i am writing a record selection formula in crystal report. can you please help me in this regard.

thanks|||go to your table expert or table expert.. you know the window with the table linked on it.
right clic on one link , link option and select RIGHT JOIN. it will be propqgqted if you've set more than one link.

Luc|||thanks a lot to all those help me, it works now

No comments:

Post a Comment