AZZA-KHAMEES
asked on
select distinct
Hi Experts
i am seeking help in writing the logic for an sql query
i have 2 tables with one to many relationship,
table1
-------------
reference
-------------
111
222
333
------------
table2
-------------------------- ---------- ---------- ---------- -
id reference status desc
-------------------------- ---------- ---------- ---------- -
1 111 initiated initiated
2 111 approved First
3 111 approved Second
4 111 assigned assigned
5 222 initiated initiated
6 222 approved First
7 333 initiated initiated
8 333 approved First
9 333 approved Second
-------------------------- ---------- ---------- --
now i need to get all references from the first table and match it with only last record from second table
ex.
Reference 333 with record id 9 from table 2
Reference 222 with record id 6 from table 2 and so on
based on condition
where status = approved or initiated
any suggestion?
i am seeking help in writing the logic for an sql query
i have 2 tables with one to many relationship,
table1
-------------
reference
-------------
111
222
333
------------
table2
--------------------------
id reference status desc
--------------------------
1 111 initiated initiated
2 111 approved First
3 111 approved Second
4 111 assigned assigned
5 222 initiated initiated
6 222 approved First
7 333 initiated initiated
8 333 approved First
9 333 approved Second
--------------------------
now i need to get all references from the first table and match it with only last record from second table
ex.
Reference 333 with record id 9 from table 2
Reference 222 with record id 6 from table 2 and so on
based on condition
where status = approved or initiated
any suggestion?
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER