Skip to main content

Notifications

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 580

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
    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
    580 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
    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

🌸 Community Spring Festival 2025 Challenge 🌸

WIN Power Platform Community Conference 2025 tickets!

Jonas ”Jones” Melgaard – Community Spotlight

We are honored to recognize Jonas "Jones" Melgaard as our April 2025…

Kudos to the March Top 10 Community Stars!

Thanks for all your good work in the Community!

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 293,998 Super User 2025 Season 1

#2
Martin Dráb Profile Picture

Martin Dráb 232,850 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,158 Moderator

Leaderboard

Product updates

Dynamics 365 release plans