Quantcast
Channel: Microsoft SQL Server
Viewing all articles
Browse latest Browse all 4871

SQL - Selecting last supplier of each product

$
0
0

So I need to pull out the last supplier of each our our products. This is what I've got so far:

SQL
SELECT[OrderLine].[Iono],[OrderLine].[Iosuf],[Lineno],[Custcode],[OrderLine].[Date],[Product],[PurchaseOrder].[Supplier]FROM[data].[dbo].[OrderLine]join[data].[dbo].[PurchaseOrder]on[OrderLine].[Iono]=[PurchaseOrder].[Iono]where[OrderLine].[Iono]in(select[Iono]from[data].[dbo].[PurchaseOrder]where[Dateinput]'2016-01-01')orderbyProduct,DateDesc
Which returns all purchase order information. How can I just get a single purchase order, which is the latest, by amending or rewriting the above?

Thanks,

Bryn


Viewing all articles
Browse latest Browse all 4871

Trending Articles