Hello everyone-
I am in need of some assistance in making an SQL query that is a bit outside of my current knowledge. It involves a table with two columns, named tblDestinations. Here's some example rows:
So as you can see it's a table of destinations. The thing is the Destination column may contain other GroupNames, as is the case for InvestmentsTeamWarning. It is it's own row, and it is also a destination for InvestmentsTeamCritical. So the groups are sort of nested in this fashion.
So I'd like to create a query that makes up a third column, something named maybe "IsGroup" that is either 'yes' or 'no' depending on whether or not it appears in the GroupName column of the table. So the desired query would return results that look like this:
So, I need help making that query.
So I obviously need Select GroupName, Destinations from tblDestinations.
Then I need to add something that checks
-if Destination IS in (Select GroupName from tblDestinations) set new IsGroup column to 'Yes'
-if Destination is NOT in (Select GroupName from tblDestinations) set new isGroup column to 'No'.
Hopefully that made sense. Could someone kindly help me form this query correctly please? Let me know if you need any more details!
I am in need of some assistance in making an SQL query that is a bit outside of my current knowledge. It involves a table with two columns, named tblDestinations. Here's some example rows:
Code:
[u]GroupName[/u] [u]Destination[/u]
Team1 Team1@email.com
Team2 Team2@email.com
InvestmentsTeamWarning BoxInvestments@email.com
InvestmentsTeamCritical InvestmentsTeamWarning
InvestmentsTeamCritical 555-555-5555
So I'd like to create a query that makes up a third column, something named maybe "IsGroup" that is either 'yes' or 'no' depending on whether or not it appears in the GroupName column of the table. So the desired query would return results that look like this:
Code:
[u]GroupName[/u] [u]Destination[/u] [u]IsGroup[/u]
Team1 Team1@email.com No
Team2 Team2@email.com No
InvestmentsTeamWarning BoxInvestments@email.com No
InvestmentsTeamCritical InvestmentsTeamWarning Yes
InvestmentsTeamCritical 555-555-5555 No
So I obviously need Select GroupName, Destinations from tblDestinations.
Then I need to add something that checks
-if Destination IS in (Select GroupName from tblDestinations) set new IsGroup column to 'Yes'
-if Destination is NOT in (Select GroupName from tblDestinations) set new isGroup column to 'No'.
Hopefully that made sense. Could someone kindly help me form this query correctly please? Let me know if you need any more details!