web
You’re offline. This is a read only version of the page.
close
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 634

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. 

I have the same question (0)
  • Suggested answer
    WillWU Profile Picture
    22,361 on at

    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

  • D365  beginner Profile Picture
    634 on at

    Hi Will Wu,

    Thanks for the reply.

    how can I use the same in X++ ?

  • WillWU Profile Picture
    22,361 on at

    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/.../

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

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Neeraj Kumar – Community Spotlight

We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…

Leaderboard > Finance | Project Operations, Human Resources, AX, GP, SL

#1
Martin Dráb Profile Picture

Martin Dráb 451 Most Valuable Professional

#2
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 428 Super User 2025 Season 2

#3
BillurSamdancioglu Profile Picture

BillurSamdancioglu 239 Most Valuable Professional

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans