DECLARE @num1 INT--The total number of rows that meet the criteria
Select @num1 =count (1) from Cardinfo where opendate between @date1 and @date2
[email protected] and @date2 for the start time to the end time, you can understand a condition
while (@num1 <>0)--the number of times a loop is formed with the following [email protected]=1
Begin
Print @num1-The value of the loop output @num1, minus one
Set @num1-=1
Select top 1 @uid = CardID from cardinfo where CardID [email protected] is the card number of the table, using pagination (1 pages per page)
Not in (select Top (@num1) CardID from Cardinfo) and--removes data from the previous (@num1-1) row
Opendate in (select Opendate from Cardinfo where opendate between @date1 and @date2)--where condition
Print @uid--loop out the desired data information
End
About outputting multiple rows of data during SQL storage