Displaying only first row for the 2nd Stored procedure

Sailee Govekar
Sailee Govekar used Ask the Experts™
on
I have two stored procedures in one report. My main stored procedure is procSSFTP_RPT_WorkAndRestDailyReport and 2nd stored procedure name is procSSFTP_RPT_GetCrewComments.

I want to display "Seafarer name" from my 1st stored procedure and "comments" from 2nd stored procedure.

I have multiple rows for the comments against the single seafarer name.

Instead of showing multiple rows of comments for single "seafarer name", I want to display one comment per "seafarer name".

Attached is the report for your reference

https://drive.google.com/open?id=1nb_DOgTVjFD1d-YdRR8jUX2omN5yO8KV
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®

Commented:
Hi,
The details can be restricted to display only once for each Seafarer name and single comment (I think this will be the comment from the first record for each Seafarer) by displaying the details under Group header section by creating a group on seafarer name. But, you also have other details like Department and Rank. Will those also be constrained to a single row display for each Seafarer?
Or you just want to display all the records for each Seafarer name and display only the comment from first record for each Seafarer name?

Author

Commented:
We need to display top comment for each seafarer. Department and Rank will be single row.

Only the concern is with One seafarer and one comment.

Commented:
Something like in attached report will do. But, when you say top comment for each seafarer name, is it the first comment or is it something associate with some value? If so, you may have to change the details accordingly. Currently, in the modified report, first comment for each seafarer will be displayed.
Report1.rpt
Learn SQL Server Core 2016

This course will introduce you to SQL Server Core 2016, as well as teach you about SSMS, data tools, installation, server configuration, using Management Studio, and writing and executing queries.

Author

Commented:
No.. its not specific. The very first comment.

and if the comment is NULL then also the seafarer name should be displayed

Author

Commented:
https://drive.google.com/open?id=12lSyQ7GszWc70wP0edmKm-yPd8BuEie-

I have multiple seafarer names. if I delete the comments then all the seafarer names are displayed.

If I add comments field then only on record is displayed. Which is wrong.

There will be list of seafarer

Commented:
That must be something to do with the link you have created between those 2 stored procs. Try changing the join from inner join to left outer or right outer join based on the data availability. You can use the report I shared (retain the comment field in the report) and check after changing the link join type.

Author

Commented:
Changing joins won't bring the correct data
Commented:
Unless you change, you will not be able to get all the Seafarer details, as the ones apart from "Espinosa, Reyland Arante" might not have comments.
Senior Consultant
Most Valuable Expert 2011
Top Expert 2013
Commented:
Can you group by seafarer and display the information in the group header?
In that way only the first comment will be displayed.
To get it to work you need to change the join as mentioned.
Changing the join will work so long as you aren't filtering on the joined table

mlmcc

Author

Commented:
It worked after changing the Joins.
Earlier we were facing some problems with the Joins so couldn't do it. But now introduced some relations to handle in Stored procedure.

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial