sql - Query compare from a table and a sum of multiple row in another table -
i have question regarding sql query , keep getting error. im trying getting qty value row in master_drawing table , compare same name sum of multiple occurences same key head_mark.
this sql
select master_drawing.total_qty totalqty, sum(master_drawing_assigned.assigned_qty) sumassignedqty master_drawing, master_drawing_assigned head_mark = 'testmultiple' , project_name = 'millhouse'
what keep getting 'ora-00918: column ambiguously defined'
am doing wrong here? in end, need compare totalqty sumassignedqty further operation
this tabe structure
master_drawing,
head_mark varchar2(20 char), entry_date date, comp_type varchar2(20 char), weight number(11,2), surface number(15,3), profile varchar2(20 char), project_name varchar2(20 char), length number(15,2) not null, total_qty number(38), subcont_status varchar2(20 char), distribution_count number
and master_drawing_assigned,
assigned_weight number(12,3), assigned_qty number(38), surface number(15,3), subcont_id varchar2(20 char), revision_no number(2), assignment_date date, project_name varchar2(20 char), id number(3), head_mark varchar2(20 char), assigned_due_date date, comp_type varchar2(25 char), signature varchar2(25 char)
try this:
select md.total_qty totalqty, mda.sumassignedqty master_drawing md inner join (select mda.head_mark, mda.project_name, sum(mda.assigned_qty) sumassignedqty master_drawing_assigned mda group mda.head_mark, mda.project_name ) mda on md.head_mark = mda.head_mark , md.project_name = mda.project_name md.head_mark = 'testmultiple' , md.project_name = 'millhouse';
Comments
Post a Comment