Hey, If I would like to have an SQL of the system ...
# suiteql
y
Hey, If I would like to have an SQL of the system notes of 3 specific fields from the sales order transaction, how should the SQL structure be. Thanks!
a
Hi, what I like to do is use a subquery to join the systemnotes table to the transaction table. Assuming your transaction table is "t", it would look like this. Of note, the type is an enum of integers, I believe 4 is "change". And the field needs to be in all caps (in my experience). This example is using aggregation, but it doesn't have to.
Copy code
left join 
	(	
		select 
		'Date' = MAX(date) 
		,recordid
			from systemnote 
		where type = '4' and field = 'YOURFIELDNAMEHERE'
		--and recordid = 106987
		group by recordid
		
	) sn
	on sn.recordid = t.id