Skip to main content

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Finance | Project Operations, Human Resources, ...
Suggested answer

Fetch Least sales price record from sales trade agreements

(0) ShareShare
ReportReport
Posted on by 578

Hi Experts,

I have a requirements that I have some customer accounts with multiple sales prices for an item in the same period. I need to take the least sales price record from the table PriceDiscAdmTrans. This is to be added in a report.  

1. Customer A with sales price 100

2. Customer A with sales price 200

3. Customer B with sales price  150

Output should be Customer A with 100 & Customer C with 150. how can I get this output using select statement?. 

Thanks in advance. 

  • WillWU Profile Picture
    WillWU 22,352 on at
    RE: Fetch Least sales price record from sales trade agreements

    Hi AX beginner,

    The ROW_NUMBER doesn't exist in X++.

    You could create a view with a computed column as the data source of the SSRS, please have a look at Martin's blog:

    dev.goshoom.net/.../

  • D365  beginner Profile Picture
    D365 beginner 578 on at
    RE: Fetch Least sales price record from sales trade agreements

    Hi Will Wu,

    Thanks for the reply.

    how can I use the same in X++ ?

  • Suggested answer
    WillWU Profile Picture
    WillWU 22,352 on at
    RE: Fetch Least sales price record from sales trade agreements

    Hi AX Beginnner,

    See the T-SQL:

    SELECT accountcode,
    AMOUNT
    FROM (SELECT *,
     ROW_NUMBER() OVER (PARTITION BY accountcode ORDER BY amount asc) AS num
     FROM PriceDiscAdmTrans) t
    WHERE num=1

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

Announcing Our 2025 Season 1 Super Users!

A new season of Super Users has arrived, and we are so grateful for the daily…

Vahid Ghafarpour – Community Spotlight

We are excited to recognize Vahid Ghafarpour as our February 2025 Community…

Tip: Become a User Group leader!

Join the ranks of valued community UG leaders

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 292,494 Super User 2025 Season 1

#2
Martin Dráb Profile Picture

Martin Dráb 231,307 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Product updates

Dynamics 365 release plans