sql insert statement with a lot of same where clause and one different where cluase
- by william
I m sry if the title is not clear.
Here's my proble.
I created a new table which will show total, average and maximum values.
I have to insert the results into that table.
That table will have only 4 rows. No Appointment, Appointment Early, Appointment Late and Appointment Punctual.
So.. I have sth like..
insert into newTable
select
'No Appointment' as 'Col1',
avg statement,
total statement,
max statement
from orgTable
where (general conditions) and (unique condition to check NO APPOINTMENT);
I have to do that same thing for another 3 rows.. where only the unique condition is different to check early, punctual or late..
So..the statement is super long.
I wanna reduce the size.. How can I achieve that?