Baanboard.com

Go Back   Baanboard.com > Forum > Baan Quick Support: Functional & Technical > Tools Development

User login

Frontpage Sponsor

Main

Poll
What do you expect from your SI Implementation partner for the success of ERP implementation.
Bring best practices - Not to offer more CR's Leveraging standard functions
14%
Need more honesty to work with the Users until their processes are fully mapped & Users are trained
43%
Focus on process automation/ integrations/ Real time data/ BI analytics
29%
Stick to basics
14%
Total votes: 7

Baanboard at LinkedIn


Reference Content

Closed Thread
 
Thread Tools Display Modes
  #1  
Old 15th March 2023, 17:50
itprog itprog is offline
Newbie
 
Join Date: Feb 2023
Posts: 2
itprog is on a distinguished road
Baan: 4 - DB: relational - OS: LN
Smile Return max sequence number of each group
Baan: Infor ERP 10.7
C/S: Client

say I have the following data set (Table1):

+----------+------------+-----------+------------+-----------+
| item | Line no | seqno | ord qty | del qty |
+----------+------------+-----------+------------+-----------+
| sls001 | 10 | 0 | 10 | 3 |
| sls001 | 10 | 1 | 7 | 5 |
| sls001 | 10 | 2 | 2 | 2 |
| sls013 | 20 | 0 | 10 | 10 |
| sls045 | 30 | 0 | 10 | 3 |
| sls045 | 30 | 1 | 7 | 0 |
| sls013 | 40 | 0 | 10 | 10 |
+------------------------------------------------------------------+


| sls001 | 10 | 2 | 2 | 2 |
I would like to group by "line no" and then select the line with the highest seq no in each group.
So in this case I would like to select the following lines:
| sls013 | 20 | 0 | 10 | 10 |
| sls045 | 30 | 1 | 7 | 0 |
| sls013 | 40 | 0 | 10 | 10 |

i did something like

domain tcpono l.seq
l.seq = 0
select item, line no, ord qty, del qty, MAX(seqno):l.seq
from Table1
where Table1.orno = {:Table2.orno}
group by line no, item, ord qty, del qty
selectdo
do some stuff......
endselect


but instead of selecting the lines with the highest "seqno" in each group, it selected every line where Table1.orno = {:Table2.orno} (the select do iterated for each record selected)

1) how do i make it so it only selects the lines with the highest "seqno" in each group

2) in the selectdo block, do I only have access to the field values that are in my select statement? Like if ord qty and del qty were not in my select statement, could i still use the ord qty and del qty values in the selectdo section?

Last edited by itprog : 15th March 2023 at 19:49.
Sponsored Links
  #2  
Old 16th March 2023, 13:46
mark_h's Avatar
mark_h mark_h is offline
Guru
 
Join Date: Sep 2001
Location: Kentucky, USA
Posts: 7,764
mark_h will become famous soon enoughmark_h will become famous soon enough
Baan: Baan 4C4 A&D1 - DB: Oracle - OS: Sun Solaris
Well the group by has order qty, del qty in it so those values are different. Unless the values were the same I would expect different sequences to show up in the results.

Well I have always done it in next queries like this:
Code:
select table1.item, table1.line, max(table1.seq)
where ......
group by item, line
selectdo
     select a.ord.qty:ord.qty  a.del.qty:del.qty
     from table1 a
      where a.item = :table1.item
      and     a.line =  :table1.line
      and     a.seqno = :table.sequence
      as set with 1 rows
      selectdo
      endselect

      .....do other stuff.....
endselect
I always kept it simple for everyone to understand - especially me. :)
__________________
Mark

GO Cards!
My latest mantra - make sure you have latest stpapi patches and the latest session object. If on LN then please explore the option of using DAL2 functionality.

Shared Solutions for Baan systems provided free by Baan Board.
Play the Google game and help Baanboard get better rankings. Do your part. Click here to find how.
Closed Thread


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Use of "background" keyword in Baan kruyoupatel Tools Development 3 24th September 2020 17:43
How to create an AFS pralash AFS/DDC/OLE: Function servers 7 11th October 2018 17:13
How to call AFS in sp24? PV Ramone AFS/DDC/OLE: Function servers 4 2nd September 2008 12:06
Audit file structure baan_user Tools Development 8 4th May 2007 15:32
Get values for Audited Field Hiba_t Tools Development 7 15th February 2007 10:26


All times are GMT +2. The time now is 01:42.


©2001-2023 - Baanboard.com - Baanforums.com