A Microsoft extension to the ANSI SQL language that includes procedural programming, local variables, and various support functions.
Could you please share us your table structure (CREATE TABLE …) and some sample data(INSERT INTO …)
along with your expected result? So that we’ll get a right direction and make some test.