logo
down
shadow

Users who work in same department


Users who work in same department

Content Index :

Users who work in same department
Tag : sql , By : adbanginwar
Date : November 24 2020, 03:01 PM

To fix the issue you can do Have a sub-query that returns the department id(s) for the employee(s) with that last name. Do IN to get the rest of the employees from same department(s).
SELECT LAST_NAME, DEPARTMENT_ID
FROM EMPLOYEES
WHERE DEPARTMENT_ID IN (select DEPARTMENT_ID
                        FROM EMPLOYEES
                        WHERE LAST_NAME = &LAST_NAME)
SELECT e1.LAST_NAME, e1.DEPARTMENT_ID
FROM EMPLOYEES e1
JOIN (select DEPARTMENT_ID
      FROM EMPLOYEES
      WHERE LAST_NAME = &LAST_NAME) e2
    ON e1.DEPARTMENT_ID = e2.DEPARTMENT_ID

Comments
No Comments Right Now !

Boards Message :
You Must Login Or Sign Up to Add Your Comments .

Share : facebook icon twitter icon

How should i map the relationship between many users and department


Tag : mysql , By : user119605
Date : March 29 2020, 07:55 AM
it fixes the issue JOINS are efficient then sub-queries.
This is what you can try using INNER JOIN
SELECT * FROM records AS r
INNER JOIN
users AS u ON (r.user_id = u.user_id)
WHERE u.department_id = 1

Count users of each department


Tag : mysql , By : user109285
Date : March 29 2020, 07:55 AM
Hope that helps I have a table with the following layout : , Use COUNT
SELECT COUNT(name),department FROM table GROUP BY department

Count all connected users on every department


Tag : mysql , By : Priyatna Harun
Date : March 29 2020, 07:55 AM
Does that help I have this tellers which can be considered as users on each service departments
(SELECT COUNT(*) FROM teller_info WHERE teller_info.`status` = "Connected" AND teller_info.service_id = service_info.service_id) AS active_teller

Powershell Script to Add New Users in AD for HR Department


Tag : windows , By : lifchicker
Date : March 29 2020, 07:55 AM
may help you . $result comes back as an integer so the path you're giving to New-ADUser looks like this:
"CN=Users,OU=0,DC=Domain,DC=com"
# ##########################################
# Determine if we have Administrator rights
Write-Host 'Checking user permissions... '
$windowsID = [System.Security.Principal.WindowsIdentity]::GetCurrent()
$windowsSecurityPrincipal = New-Object System.Security.Principal.WindowsPrincipal($windowsID)
$adminRole = [System.Security.Principal.WindowsBuiltInRole]::Administrator

If (!($windowsSecurityPrincipal.IsInRole($adminRole))) {
    Write-Warning 'Current user does not have Administrator rights'
    Write-Host 'Attempting to copy files to temporary location and restarting script'

    # Get random file name
    Do {
        $temp = [System.IO.Path]::GetTempPath() + [System.IO.Path]::GetRandomFileName()
    } Until (!(Test-Path -LiteralPath "$temp"))

    # Create directory
    Write-Host 'Creating temp directory... ' -NoNewLine
    New-Item -Path "$temp" -ItemType 'Directory' | Out-Null
    Write-Host 'done.'

    # Copy script to directory
    Write-Host 'Copying script to temp directory... ' -NoNewLine
    Copy-Item -LiteralPath "$($myInvocation.MyCommand.Path)" "$temp" | Out-Null
    Write-Host 'done.'
    $newScript = "$($temp)\$($myInvocation.MyCommand.Name)"

    # Start new script elevated
    Write-Host 'Starting script as administrator... ' -NoNewLine
    $adminProcess = New-Object System.Diagnostics.ProcessStartInfo
    $adminProcess.Filename = ([System.Diagnostics.Process]::GetCurrentProcess()).Path
    $adminProcess.Arguments = " -File `"$newScript`""
    $adminProcess.Verb = 'runas'

    Try {
        [System.Diagnostics.Process]::Start($adminProcess) | Out-Null
    }
    Catch {
        Write-Error 'Could not start process'
        Exit 1
    }
    Write-Host 'done.'

    Exit 0
}
#Change the execution policy
Set-ExecutionPolicy bypass
#Import the AD module
Import-Module ActiveDirectory
#Set variables

$title = "Add Users To The Domain"
$message = "For which department do you wanna add this user to?"

$rn = New-Object System.Management.Automation.Host.ChoiceDescription "&RN", `
    "RN"

$callcenter = New-Object System.Management.Automation.Host.ChoiceDescription "&Call Center", `
    "Call Center"

$management = New-Object System.Management.Automation.Host.ChoiceDescription "&Management", `
    "Management"

$billing = New-Object System.Management.Automation.Host.ChoiceDescription "&Billing", `
    "Billing"

$options = [System.Management.Automation.Host.ChoiceDescription[]]($rn, $callcenter, $management, $billing)

$result = $host.ui.PromptForChoice($title, $message, $options, 0) 

switch ($result)
    {
        0
        {
            "You selected RN."
            $OU = "RN"
        }
        1
        {
            "You selected Call Center."
            $OU = "CallCenter"
        }
        2
        {
            "You selected Management."
            $OU = "Management"
        }
        3
        {
            "You Selected Billing."
            $OU = "Billing"
        }
    }


$UName = Read-Host "What is the username you wanna give? Make sure it matches the username in the email."
$FName = Read-Host "What is the Full Name of the user?"


New-ADUser `
 -Name $FName `
 -Path  "CN=Users,OU=$OU,DC=Domain,DC=com" `
 -SamAccountName  $UName `
 -DisplayName $FName `
 -AccountPassword (ConvertTo-SecureString "password1" -AsPlainText -Force) `
 -ChangePasswordAtLogon $true  `
 -Enabled $true
Add-ADGroupMember "Users" "$UName";

How to show the users of this specific department?


Tag : php , By : Epora75
Date : March 29 2020, 07:55 AM
should help you out Change you method like this, you need to find department by id passed to route and then get department users. You can also do it using eager loading.
EDITED: You don't have to take id from request, but as route param, so this have to work
public function usersdep($id){
    $department = Department::with('users')->find($id);
    return view('admin.page-users')->with('users', $department->users);
}
Related Posts Related QUESTIONS :
  • SQL query for a database scheme
  • Timer-based event triggers
  • SQL query, count and group by
  • Paging SQL Server 2005 Results
  • SQL Server 2005 For XML Explicit - Need help formatting
  • How do I use T-SQL Group By
  • How do I split a string so I can access item x?
  • Date Condition with Case when Holiday exclude
  • SQL Query Select from 1 table and return data based on 2 columns
  • how to use rank/join and where together
  • How to create new column with values counting up every 9th value with SQL?
  • Most frequent combination of words/characters SQL Server
  • Why can't I access a field defined as "Select 1" from a subquery in the outer query?
  • How to solve Msg 8115, Level 16, State 2, Line 2 Arithmetic overflow error converting expression to data type int.?
  • UPDATE row inserted earlier in CTE
  • Display current month values based upon abbreviation (Oct) SQL Server
  • SQL Modify returned select value without union
  • How to put a variable in a like statement in vba?
  • More Elegant way to Batch Validate Phone Numbers
  • SQL find parent where children match over multiple rows
  • A combo box that has to be filter the same data in that field
  • Exclude updated record from trigger function
  • Insert into table from select only when select returns valid rows
  • How to fix SQLite3::SQLException: near "to": syntax error: SELECT "".* FROM "" WHERE "
  • Filter msdb.dbo.sysjobsteps.command into seperate columns
  • How to extract year or month,day from oracle function without using sub-query?
  • Reset sum when condition is met in Oracle
  • Date Between (Start & Now)
  • Reset running sum when condition is met in Oracle
  • Why is my date criteria filtering incorrectly in a MsysObjects query using DCount?
  • Stripping date/time delimiters in an SSIS csv export
  • SSIS Error on insertion - Error when new primary keys in Dimension table
  • How can I make a temp table of specific datetime data within a range?
  • AnalysisException: Syntax error in SQL After multiple join
  • SQL Query Multiple Columns Using Distinct on One Column Only and Using Order By
  • Sum inventory item groups
  • TSQL: Parsing strings with various characters
  • Using SQL Server : how to use select criteria based on sum
  • Inserting dynamic pivot Result into Temp table
  • Joining multiple fields in a dataset joined with descriptions
  • Conditional WHERE EXISTS in Oracle query
  • How to get the count of each unique value in a column between two dates?
  • SQL: Select only if multiple values are IN 1 column from CatalogTable
  • In a query (no editing of tables) how do I join data without any similarities?
  • Create nested json blobs in PostgreSQL
  • Getting extra dates while using cte
  • Way to alter one table if another was altered
  • Proper use of semicolons in functions and procedures
  • Cursor Not looping all the Records
  • Select inner join returns wrong result
  • Group By showing duplicates
  • Error in using subquery in access join query
  • How do I use a composite pk in a stored procedure?
  • Oracle Unique Indexes
  • Spooling data to CSV truncates
  • How do views reduce code duplication?
  • SQL: Gather right hand values from a join
  • SQL Agent Logon - What is going on?
  • How do I combine two rows of same part, but add quantities?
  • How to optimize this SQL query for a rectangular region?
  • shadow
    Privacy Policy - Terms - Contact Us © scrbit.com