I have a table that has account_id, visit_type, encounter_id and others fields. The same account_id can have more than one type of visit, but with a different encounter_id. I am trying to build a query that will search all the orginal table for all account_id's that have a visit_type of 1. Then I need to search the resulting account_id's to see if they also have a visit_type of 2 in the orginal table.
So is there a way to do a search and build a temp table, then take the account_id from the temp table and do another search on the orginal table and then combine the results where the two temp tables match?
I was looking at joins, but they seem to use two orginal tables and joining these to get the results, where I have one table to work from.
TIA
So is there a way to do a search and build a temp table, then take the account_id from the temp table and do another search on the orginal table and then combine the results where the two temp tables match?
I was looking at joins, but they seem to use two orginal tables and joining these to get the results, where I have one table to work from.
TIA