web
You’re offline. This is a read only version of the page.
close
Skip to main content

Announcements

No record found.

News and Announcements icon
Community site session details

Community site session details

Session Id :
Small and medium business | Business Central, N...
Suggested Answer

How to select only distinct records from a table?

(0) ShareShare
ReportReport
Posted on by 625

Hi All,

I am quite new to NAV. I want to select distinct rows from a table? 

Thanks in Advance.

  • Saurav.Dhyani Profile Picture
    14,481 User Group Leader on at

    Hi Axboy,

    Can you provide an example and for which version of NAV / BC?

  • AXBOY Profile Picture
    625 on at

    It's for business Central.

    I have to select all the records from JoB table whose type is resource and that too resource.typpe: Person. Then from these records I want only those records whose person name is unique.

  • Suggested answer
    Saurav.Dhyani Profile Picture
    14,481 User Group Leader on at

    I think you are referring table Resource not Job.

    Below code sample will show those unique Resource Name -

    LOCAL GetUniqueResources()

    Resource.RESET;

    Resource.SETCURRENTKEY("Name");

    Resource.SETRANGE(Type,Resource.Type::Person);

    IF Resource.FINDSET THEN REPEAT

     IF PrevResourceName = Resource.Name THEN

       MESSAGE('%1',Resource.Name);

     PrevResourceName := Resource.Name;

    UNTIL(Resource.NEXT=0);

    I hope it helps.

  • AXBOY Profile Picture
    625 on at

    Hi Saurav, thanks for the reply.

    I have Job No. with me , and using that i want to build a string with Job.Description , of planning lines type=resource, resource.type=person with unique Job.No values. Can u pls help me with this?

  • Saurav.Dhyani Profile Picture
    14,481 User Group Leader on at

    You need to share an example what you want before i can help you.

  • AXBOY Profile Picture
    625 on at

    I am building a report where the user will select a Job Number and based on that number report will print data from the Job Planning lines related to that Job Number.

    Now for one of the fields ,i have display a string in the form: JobPlanning.Description1,JobPlanning..Description2, JobPlanning.Description3.....etc , where JobPlanning.Type = Resource and that Resource.Type= Person.

    I am able to achieve till here, but i want the String to have unique Description , that is i do not want that string to contain duplicate Person names. Hope you get my point.

  • Saurav.Dhyani Profile Picture
    14,481 User Group Leader on at

    Sorry, I still didnt understand.

    I may need some sample data to understand requirment.

  • Suggested answer
    Raju Gudipalli Profile Picture
    185 on at

    Use code like this to eliminate the duplicates

    Mydescription : text;

    If strpos(mydescription,jobplanninglines.description)  = 0 then

    Mydescription += jobplanninglines.description.

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Season of Sharing Community Challenge Winners!

Congratulations to our community stars!

Women in Power Builds Momentum

Expanding mentorship, skilling, and AI innovation

Leaderboard > Small and medium business | Business Central, NAV, RMS

#1
OussamaSabbouh Profile Picture

OussamaSabbouh 633 Super User 2026 Season 2

#2
YUN ZHU Profile Picture

YUN ZHU 419 Super User 2026 Season 2

#3
Teagen Boll Profile Picture

Teagen Boll 236 Super User 2026 Season 2

Last 30 days Overall leaderboard

Featured topics

Microsoft Training Manuals

Product updates

Dynamics 365 release plans