How can I prevent duplicate values in SQL? -


i can't think of title question here goes..

i have sql query

select   j.srv_job_id,   c.unit_cost * c.qty cost_price,   e.serial_no   srv_job j   left join srv_job_cost c       on c.srv_job_id       = j.srv_job_id   left join srv_job_equipment je on je.srv_job_id      = j.srv_job_id   left join srv_equipment e      on e.srv_equipment_id = je.srv_equipment_id   j.srv_job_id = 52423 

which simplified purpose of question, , gives these results;

srv_job_id  cost_price serial_no 52423       89         400887 52423       89         400888 52423       89         400889 

because there 1 job id of 52423 , cost of 89, there 3 associated serial numbers.

there nothing wrong result, misleading because looks each serial number has cost of 89, when in fact total cost 3 89.

how can prevent cost of 89 being duplicated? can't change database schema, can change query.

the result be

srv_job_id  cost_price serial_no 52423       89         400887 52423       null       400888 52423       null       400889 

i've broken 2 separate queries. 1 list job(s) details , 1 list serial numbers each job.

thanks help. comments led me thinking problem differently.


Comments

Popular posts from this blog

Android layout hidden on keyboard show -

google app engine - 403 Forbidden POST - Flask WTForms -

c - Why would PK11_GenerateRandom() return an error -8023? -