I know I am beating a dead horse here it seems like, but I have messed with this for an hour, trying all the examples I can find and nothing seems to be doing it for me. Below is a very dumbed down version of what I am going after. In my real world solution I am querying like 14 columns, with 2 joins and only like 3 conditions.
select distinct 
        d.rental_ticket,
        i.Invoice_Number
from HP_View_DEL_Ticket_Header_Master as d
join CSView_INVC_Header_Master as i
on d.Rental_Ticket = i.Rental_Ticket_or_Tag_Number
where d.Ticket_Month <= '6'
and d.Ticket_Year = 2014
order by Rental_Ticket
I get something like this
Rental    Invoice
3023    3127
3146    3074
3215    3103
3235    3167
3245    3054 -- dup
3245    3055 -- dup
3249    3081
3251    3214
3255    3102
3261    3099
3267    3098
3276    3056
I know since I am using distinct with multiple columns it will filter down to all combinations. well like many, I just need to see the rental number once, no matter how many invoices it has.
in my live query, I am using a condition that is looking for a code, CRT, I only want to see one line of data for (in turn on rental number) no matter if there is only one or 10 CRT codes present
I threw this in there based on another person example but it seemed to do nothing
where d.Rental_Ticket in (select max(Rental_Ticket) as rental_ticket from HP_View_DEL_Ticket_Header_Master as d group by d.Rental_Ticket)
any help will be greatly appreciated!!
UPDATE:
select  d.rental_ticket, max(i.invoice_number) as Invoice_Number,
        d.Reference_Location1 as Rig, max(d.Rental_Ticket)
from HP_View_DEL_Ticket_Header_Master as d
join CSView_INVC_Header_Master as i
on d.Rental_Ticket = i.Rental_Ticket_or_Tag_Number
where d.Ticket_Month <= '6'
and d.Ticket_Year = 2014
group by d.Rental_Ticket, d.Reference_Location1
order by Rental_Ticket
this give me 4 columns, when really I am only going to need 2 (Rental_Ticket and Rig) thanks BD
 
     
     
    