instead of
MAX(survey_questions.question_type) as question_type
I would like something like
LAST (survey_questions.survey_id ) survey_questions.question_type as question_type
My table survey_questions has list of questions for various surveys. Higher the survey_id the more recent the question - we keep a list of the wording of the question for various iterations of the survey, sometimes the type of question changes (drop down, text, etc). The problem comes in my 'view' created this way
select report_survey_questions.report_id,
report_survey_questions.report_question_number,
MAX(survey_questions.question_type) as question_type,
MAX(CAST(survey_questions.client_provided_data_id as int)) as client_provided_data_id
from report_survey_questions,
survey_questions
where report_survey_questions.survey_id = survey_questions.survey_id
and report_survey_questions.question_id = survey_questions.question_id
group by report_survey_questions.report_id,
report_survey_questions.report_question_number
So how can I instead of MAX get last (ie the highest survey_id), maintaining all the other parts.