Skip to content
Advertisement

Rewrite MS Access SQL statement to SQL Server

I wish to convert the following MS Access SQL statement to SQL Server. All of my attempts are resulting in different results from the old & original data.

The new Query is:

The problem caused by grouping date column in new statement, but in old one it is used in Last function to avoid grouping it and still exists in the select statement, How can I do like this.

Advertisement

Answer

You can try the below query. Changes to the original:

  • empty string is note as '' instead of ""
  • I replace LAST with MAX(); this is likely to do what you want, since you are using aggregation
  • constant columns do not need to be listed in the GROUP BY clause

Code:

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