Skip to content
Advertisement

Define two or more conditions into a stored procedure with inner join?

First, I needed to filter the data from the tables TbTaxCompanies and tbCompany, through the variable @company_id… and works!

And second I need to filter again the set of logs from the company selected previously with @company_id, but now to obtain only the latest updated taxes (only one row)… and this DOES NOT WORK!

I really appreciate any help.

Advertisement

Answer

If you want the latest row from the first resultset, just use order by and top:

If you want the latest row per group, for example per tc.idtaxcompany, then you can just change the ORDER BY clause to:

User contributions licensed under: CC BY-SA
7 People found this is helpful
Advertisement