Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Get delegate from a table of delegates

Status
Not open for further replies.
Jul 28, 2011
167
NG
Hi guys,

I have a table named 'tbl_slo_approver_users' that looks like this

id | type | sequence | delegate_level | user_name | email | delegated
1 | SLO | 1 | 0 | aaa | aaa@gmail.com | 0
2 | SLO | 2 | 0 | bbb | bbb@gmail.com | 0
3 | SLO | 3 | 0 | ccc | ccc@gmail.com | 0
4 | SLO | 1 | 1 | ddd | ddd@gmail.com | 0
5 | SLO | 1 | 2 | eee | eee@gmail.com | 0
6 | GRD | 1 | 0 | fff | fff@gmail.com | 0
....

This table is a table showing people that can approve different types of request (SLO, GRD, etc)

What I want to achieve is such that by default, the person with sequence 1 should be the person to approve a request. However, there is a possibility of him delegating the resposibility to his subordinate; thereby, delegated should be 1 allowing for the subordinate to be able to approve.

Thus, suppose SLO is the stuff to be approved, then the person to approve by default is aaa. If aaa is absent, then, delegated should be 1 so that ddd (who is on thesame sequence of 1 for SLO) will be able to approve. If ddd is absent, then his own delegated also should be 1 allowing for eee (who is also in thesame sequence of 1 for SLO) to be able to approve.

What I want now is a query that will pull the record for eee (assuming aaa and ddd have a delegated of 1).

I hope I've been able to explain my situation
 
I had always known the query was a simple one just could not figure it out in the past 5 days.

All I needed to do was to use the keyword TOP 1 in order to limit the query to the first non-delegated user

Sorry for wasting your precious time. [wink]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top