Say I have 2 tables:
Table 1
Name - Toys - broken - recurrence
Jack 6 4 0
John 8 3 1
Mark 8 2 2
Jack 4 2 1
John 3 3 1
Mark 6 0 2
Table 2:
Name - Toys - recurrence
COlumn Name: name
Column Toys: average of (Jack, John and Mark)'s toys (each a different record).
Column recurrence: average of the 'broken' field when the recurrence is 1;
My main issue here is how to write a statement to insert data from table 1
into table 2 with the correct calculations. I was assuming there would be 2
'Where' clauses needed.. but I am not too sure how to write the statement.
I know this will give me the averages in the Toys column per person:
insert into table2 (Toys, recurrence, name) select name,avg(Toys),recurrence from table1
group by name;
But how to I edit this statement so that it will also give me the recurrence column
which has a different 'where' statement, as in where recurrence='1';
HDRG 0 Newbie Poster
LastMitch
Be a part of the DaniWeb community
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.