Jump to content

packrat

Members
  • Posts

    61
  • Joined

  • Last visited

Posts posted by packrat

  1. I've been through quite an ordeal trying to get registered in order to drop you this chunk of sql, ... sure hope it works. Much thanks to the admins for getting me going. Try plugging your variable names into the sql below. I haven't tested this solution, if its buggy I might be able to help. if you get an error in the 'where' try changing the '=' to 'IN'. let me know how it pans out. --answer to complex select

    SELECT [year], [month], [day]FROM [table] WHERE [table].[year] =  (  SELECT TOP 1 [year] FROM [table] WHERE [year]=0 OR [year]=@year  GROUP BY [year] HAVING COUNT([year]) > 0 ORDER BY [year] DESC ) AND [table].[month] = (  SELECT TOP 1 [month] FROM [table] WHERE [month]=0 OR [month]=@month  GROUP BY [month] HAVING COUNT([month]) > 0 ORDER BY [month] DESC ) AND [table].[day] = (  SELECT TOP 1 [day] FROM [table] WHERE [day]=0 OR [day]=@day  GROUP BY [day] HAVING COUNT([day]) > 0 ORDER BY [day] DESC )

    //PackRat

×
×
  • Create New...