SQL BUG set "NewID () problem in random sort

zhaozj2021-02-16  73

/ ** == ** 2. NEWID () question in random sort ** == ** / - Test data declare @t table (name char (1), value int) Insert Into @tselect 'a', 1Union All Select 'a', 2UNION All Select 'B', 3UNION All Select 'C', 5Union All Select 'C', 6

- Requires, random sort, but Name is the same to be ranked in a SELECT A. * From @ta join (Select aa = newid (), name from (Select Distinct Name from @t) b on a.name = B .nameorder by B.AA, NewID ()

/ * - One of the test results did not meet the requirements. If Join is changed to Left Right Full Join, it is correct Name Value ---- ----------- B 4B 3C 5A 1A 2C 6

(The number of rows affects is 6 lines) - * /

转载请注明原文地址:https://www.9cbs.com/read-12363.html

New Post(0)