Hello,
I would like to know how to write the code only once since my two queries are identical except for the age.
Thanks a lot for any hint.
SET @nb_0 =
(SELECT count (*)from
(SELECT distinct client_id
from main m inner join client p
on m.client_id = p.client_id
where (location_id = @location_id) AND (age_id between 1 AND 7)
AND year ( date_done) = @year_of_request
) a
)
SELECT 'age 0-29:',@nb_0
SET @nb_30 =
(
SELECT count (*)from
(SELECT distinct client_id
from main m inner join client p
on m.client_id = p.client_id
where (location_id = @location_id) AND ( age_id between 8 AND 15)
AND year ( date_done) = @year_of_request
) a
)
SELECT 'age 30-90:',@nb_30
I would like to know how to write the code only once since my two queries are identical except for the age.
Thanks a lot for any hint.
SET @nb_0 =
(SELECT count (*)from
(SELECT distinct client_id
from main m inner join client p
on m.client_id = p.client_id
where (location_id = @location_id) AND (age_id between 1 AND 7)
AND year ( date_done) = @year_of_request
) a
)
SELECT 'age 0-29:',@nb_0
SET @nb_30 =
(
SELECT count (*)from
(SELECT distinct client_id
from main m inner join client p
on m.client_id = p.client_id
where (location_id = @location_id) AND ( age_id between 8 AND 15)
AND year ( date_done) = @year_of_request
) a
)
SELECT 'age 30-90:',@nb_30