Select Top 12 ID, URL, titleorname from t_userscolumn A where Mark = '1' and not exists (select * From t_userscolumn where url =. URL and titleorname =. titleorname and Mark = '1' and ID>. ID) order by ID DESC
========================================================== ========
Remove duplicate values from SQL Server 2000
the table structure is zymc -- major name, NJ -- grade, xnxqh -- academic year number, xxlb -- Study class, XF -- credits, xs -- hours
zymc NJ xnxqh kcmc kcxz XF Xs
AA 2001 20041 2001 English 1 3 60
AA 20041 2001 English 1 0 60
AA 20041 English 2 3.5 70
BB 2002 20041 mathematics 1 5 90
BB 2002 20041 mathematics 1 0 90
BB 2002 20041 mathematics 1 4.5 90
BB 2002 mathematics 1 4 80
BB 2001 20041 physical 1 0 80
expected results:
zymc NJ xnxqh kcmc kcxz XF Xs
AA 2001 20041 english 1 3 60
BB 2002 20041 mathematics 1 5 90
BB 2001 20041 physical 1 0 80
when credits are 0 and non-0 and non-0 values are greater take the first non-0 value for a row, if there is only one row, the credit is 0 and the number of rows is retained
after the duplicate value is removed, you can create primary keys for the tables in zymc, NJ, xnxqh, and kcmc
Primary
Because of the same zymc, NJ, xnxqh, and kcmc, you only need to keep one record, so take the same zymc, NJ, xnxqh, the maximum XF value of kcmc data can meet your requirements.
Select * from Table
Where not exists (select * from table where zymc = A. zymc and nj = A. NJ and xnxqh = A. xnxqh and kcmc = A. kcmc and XF> A. xf)
---------------------------------------------------------------------------------
This is the case if you delete unwanted records.
Delete A from Table
Where exists (select * from table where zymc = A. zymc and nj = A. NJ and xnxqh = A. xnxqh and kcmc = A. kcmc and XF> A. xf)
--------------------------------------------------------------------------------