Recreate SQL Query in BAQ

Hey everyone,
I am trying to recreated this Query in a BAQ. Is there a way to get the
Top(1) with ties

and the
order by ROW_NUMBER() over (partition by a.PartNum order by a.TranDate desc)

in a BAQ?

Full Query below:

select
Top(1) with ties
Max(a.TranDate) as LastTranDate,
a.PartNum,
a.TranType,
a.TranQty
from erp.PartTran a
where a.Company = ‘PPI’ and a.TranType in (‘STK-CUS’)
group by a.PartNum,
a.TranType,
a.TranQty,
a.TranDate
order by ROW_NUMBER() over (partition by a.PartNum order by a.TranDate desc)

There’s a checkbox right here for “With ties”. The windowing functions work just fine as a calculated field.

1 Like

I can’t believe I missed that. I got around it using ROW_NUMBER() then selecting where row number = 1.