I need to pull information out of a SQL db using a query.
I need to generate a final status of "Locked"or "Unlocked" for each computer in our organization. In order to find out whether the PC is locked down, I have to evaluate what is contained in the SMX_Local_Admins_DATA.Account00 field for each PC. This is a one to many relationship. For each PC, there an be multiple records. So, for each PC if the Account00 field contains a record that is other than "desktop", "security", or "admin" then that PC is unlocked else the PC is locked. I cannot figure out how to write this in SQL. So far, I have tried the following code, but it is not giving me the desired result. I suspect that I might need a variable to hold the value of "Locked" or "Unlocked", but I am not sure.
SELECT
count("Computer_System_Data"."Name0") as Cnt, "Computer_System_Data"."Name0"
FROM
"Computer_System_Data" "Computer_System_Data", "SMX_Local_Admins_DATA" "SMX_Local_Admins_DATA"
WHERE
right("SMX_Local_Admins_DATA"."Account00",len("SMX_Local_Admins_DATA"."Account00")-{fn locate('root\',"SMX_Local_Admins_DATA"."Account00")} +1) not in ('admin','desktop','security')
Group by
"Computer_System_Data"."Name0"
I need to generate a final status of "Locked"or "Unlocked" for each computer in our organization. In order to find out whether the PC is locked down, I have to evaluate what is contained in the SMX_Local_Admins_DATA.Account00 field for each PC. This is a one to many relationship. For each PC, there an be multiple records. So, for each PC if the Account00 field contains a record that is other than "desktop", "security", or "admin" then that PC is unlocked else the PC is locked. I cannot figure out how to write this in SQL. So far, I have tried the following code, but it is not giving me the desired result. I suspect that I might need a variable to hold the value of "Locked" or "Unlocked", but I am not sure.
SELECT
count("Computer_System_Data"."Name0") as Cnt, "Computer_System_Data"."Name0"
FROM
"Computer_System_Data" "Computer_System_Data", "SMX_Local_Admins_DATA" "SMX_Local_Admins_DATA"
WHERE
right("SMX_Local_Admins_DATA"."Account00",len("SMX_Local_Admins_DATA"."Account00")-{fn locate('root\',"SMX_Local_Admins_DATA"."Account00")} +1) not in ('admin','desktop','security')
Group by
"Computer_System_Data"."Name0"