MySql Condition Clause resulting in every joined line from joined table based on column value

18 views Asked by At

The following are the related lines of my query that I have a problem I cannot resolve:

IF (servicesalesdetailsopen_v.complaintcode LIKE 'IVWIP', 'Y', 'N') as intflag

LEFT JOIN servicesalesdetailsopen_v

ON servicesalesopen_v.ronumber = servicesalesdetailsopen_v.ronumber and servicesalesopen_v.vehid = servicesalesdetailsopen_v.vehid and servicesalesdetailsopen_v.cora_acct_code = 'XXX-S'

The query brings back accurate results but line by line for detailed line items within the servicesalesdetailsopen table. I only want a Y set as intflag if IVWIP is on ANY row in the servicesalesopen_v.complaintcode for the repair orders and it brings back every line item with a Y or an N for each line. I would like the result in one line by RO.

How do I accomplish one line results by RO?

This is ongoing. I don't want to have to address it when it's imported into another database.

0

There are 0 answers