I MySQL kan du bruge substring_index()
og aggregering:
select o.quoteId, o.salesorderid,
max(q.quote_id)
from orders o left join
quotes q
on o.quoteId = substring_index(q.quoteId, '-', 1)
group by o.quoteId;
I SQL Server (eller MySQL også), kan du bruge LIKE
til sammenligning:
select o.quoteId, o.salesorderid,
max(q.quote_id)
from orders o left join
quotes q
on q.quoteId like concat(o.quoteId, '-%')
group by o.quoteId;