Question : Select Join quetion

I have two Tables, such as InvoiceHeader and InvoiceDetail. I want to join them (on InvoiceHeaderID) but while there are many in the InvoiceDetail side I only want to bring in one row, anyone  row would do. Can this be done?

Answer : Select Join quetion

Try this one
1:
2:
3:
4:
5:
6:
7:
8:
select * 
from invoiceHeader a
INNER JOIN
(
      select *,ROW_NUMBER() OVER (PARTITION BY invoiceHeaderID ORDER BY invoiceHeaderID) AS Row  
      from invoicedetail
) X on a.id = X.invoiceHeaderID
WHERE X.Row=1
Random Solutions  
 
programming4us programming4us