I'm looking for the Location of a Sales Order. I'm...
# suiteql
s
I'm looking for the Location of a Sales Order. I'm doing this: ----------------------------------------------------------------------- select top 10 transaction.id, transactionline.location from transaction inner join transactionline on transactionline.id = (select min(id) from transactionline where transactionline.transaction = transaction.id) where type = 'SalesOrd' ------------------------------------------------------------------------ Is it the best way ? Thanks
a
Copy code
SELECT 
  t.id, 
  l.location,
  BUILTIN.DF(l.location) as locationname
FROM 
  transaction t 
  INNER JOIN transactionline l on t.id = l.transaction 
WHERE 
  t.type = 'SalesOrd' AND
  l.mainline = 'T'
FETCH FIRST 10 ROWS ONLY
If you only want location for sales orders by the main line then adding the mainline = 'T' would be needed kind of like searches. JOIN syntax for tables can be found in the records catalog (.../app/recordscatalog/rcbrowser.nl) SELECT TOP 10 is similar to FETCH FIRST 10 ROWS ONLY, just another way to do it. BUILTIN.DF gets the name of the location, but you can also add another join to the location table to get that data
s
Good. I forgot about the mainline. Thanks a lot