Working with Join for Latest row aaded of each master table row?
<p>These are my two tables, <code>Leadid</code> is Primary Key.</p>

<p>Table1 - (Master)   </p>

<pre><code>Leadid  Customer Name
101     Ramesh Kumar
102     Rajan Kumar
103     Rahul Kumar
</code></pre>

<p>Table2 - (Transaction)</p>

<pre><code>id  Leadid  Followed_by
1   101     SAKSHI
2   101     MADHURI
3   101     SAKSHI
4   102     SAKSHI
5   102     MADHURI
6   103     SAKSHI
7   103     SAKSHI
</code></pre>

<p>Question : I need a common query where i will change only FOllower Name and </p>

<p>IN CASE OF MADHURI RESULT SHOULD BE:</p>

<pre><code>102        Rajan Kumar     5   102     MADHURI
</code></pre>

<p>IN CASE OF SAKSHI RESULT SHOULD BE:</p>

<pre><code>101     Ramesh Kumar      3     101     SAKSHI
103     Rahul Kumar       7     103     SAKSHI
</code></pre>

<p>if same lead id is followed by others, previous transcation should not be included...</p>

<p>i e Leadid 101 was followed by madhuri also but then after followed by SAKSHI. </p>

<p>so it should not be displayed when putting query for MADHURI.</p>

<p><a href="http://sqlfiddle.com/#!9/a4fbb" rel="nofollow">http://sqlfiddle.com/#!9/a4fbb</a></p>