[SQL]查询每一天的一条记录

WITH  NewTable  AS (
SELECT  companyID,companyName,registerDate,
RANK() 
OVER (PARTITION  BY     CONVERT ( VARCHAR ( 10 ),registerDate, 120 )   Order   BY    registerDate  ) RANK
FROM    b_companys)
SELECT   *   FROM  NewTable
WHERE  RANK  <   2   ORDER   BY  registerDate  DESC  

你可能感兴趣的:(sql)