title: Sql query to select last row along with other columns which are retrieved using inner join
body: <p>I have three tables from three different databases. I have to retrieve multiple columns from these three tables, which I did by using inner join.
  Now I have to retrieve only that row that is recently updated i.e. the last row. How do I retrieve the last row along with multiple columns from different databases?</p>
  
  <p>My sql query is </p>
  
  <pre><code>SELECT a.logtime, a.BL1_data_SS_ST, a.BL2_data_SS_ST, a.BL3_data_SS_ST, 
  a.BL4_data_SS_ST, a.BL5_data_SS_ST, a.BL6_data_SS_ST, a.BL7_data_SS_ST, 
  a.BL8_data_SS_ST, a.BL9_data_SS_ST, a.BL10_data_SS_ST, a.BL11_data_SS_ST,
  a.BL12_data_SS_ST, a.BL13_data_SS_ST, a.BL14_data_SS_ST, a.BL15_data_SS_ST, 
  a.BL16_data_SS_ST, a.BL17_data_SS_ST, a.BL18_data_SS_ST, a.BL19_data_SS_ST, 
  a.BL20_data_SS_ST, a.BL21_data_SS_ST, a.BL22_data_SS_ST, a.BL23_data_SS_ST, 
  a.BL24_data_SS_ST, a.BL25_data_SS_ST, a.BL26_data_SS_ST, a.BL27_data_SS_ST,
  b.st1_prmt_status_p45, c.beam_current, c.beam_energy
  
  FROM INDUS2_BLFE.dbo.main_BLFE_status a 
  INNER JOIN INDUS2_MSIS.dbo.main_MSIS_status b on a.logtime = b.logtime 
  INNER JOIN INDUS2_BDS.dbo.DCCT c on b.logtime = c.logtime ''
  </code></pre>