Let's say i have a database with the following structure and data
tablename: customers
customerID| customername | PictureID|
1 | MyCustomer | 1.jpg |
1 | MyCustomer | 1_1.jpg |
1 | MyCustomer | 1_3.jpg |
2 | MyCustomer2 | 2.jpg |
3 | MyCustomer3 | 3.jpg |
3 | MyCustomer3 | 3_2.jpg |
4 | MyCustomer4 | 4_2.jpg |
4 | MyCustomer4 | 4_1.jpg |
Is it possible to pull back only one entry per customer? I don't care
which Picture ID it uses. I would perfer if the query would return the
topmost PictureID for a customer, but i don't really care.
desired output
customerID| customername | PictureID|
1 | MyCustomer | 1.jpg |
2 | MyCustomer2 | 2.jpg |
3 | MyCustomer3 | 3.jpg |
4 | MyCustomer4 | 4_2.jpg |
I have tried using the DISTINCT keyword, but it does not really help
me. my original thought was to use...
"Select Distinct CustomerID, Customername from Customers" but then i
don't have access to the PictureID? can i use a sub query?