I got a test task
There are 2 tables of the following content: Table A:
Референс договора на кредитную карту REP_REF (тип поля текстовый) Бранч (код отделения) договора ECA_BRNM (тип поля текстовый) Логин сотрудника, за которым закреплен договор LDAP_EXPERT (тип поля текстовый) Table B:
Логин сотрудника LDAP_LOGIN (тип поля текстовый) Бранч (код отделения) сотрудника ECA_BRNM (тип поля текстовый) Код бизнеса сотрудника BUS_BUS (тип поля числовой) Код должности сотрудника POSIT_POS (тип поля текстовый) Task: Select all contracts that are assigned to an employee working on a brunch that does not match the branch of the contract or if the specified employee is not in table B. Find in table B the employee who works on the brunch of the contract. ------- in which there is one of the conditions
4) if several employees of the above-mentioned businesses are found on the brunch, then distribute the agreements evenly between them
I try to use
COUNT(DISTINCT LDAP_EXPERT) AS exp_cnt FROM A into #EXP_COUNT IF (#EXP_COUNT.exp_cnt ) > 1 NTILE(2) OVER(PARTITION BY REP_REF ORDER BY LDAP_EXPERT) gr FROM BUS_BUS ORDER BY *********??. but it seems to me that this is total murk. How to use this function for this condition? or you can do simple things
logically, should work like this
you need to count the number of contracts and the number of employees, between which you need to distribute them further, number the contracts in a row (from 1 to the number of employees) and number the employees further to the table with the contracts, join the table with the employees on the condition that the number of the contract coincides with the number of the employee
help make a request