Conditional Filter

  • I am looking for a more rapid way to filter a table with a compound keyfield.

    The two fields that I would like to filter on are KeyCode & EffectiveDate. If the KeyCode field is not unique, I would then (and only then) like to evaluate the EffectiveDate and return the most recent record.

    I can see how to do it with 2 or 3 pass-through queries, but I would like to use one streamlined query. If anyone has a suggestion, I am open to hear it. Please copy replies to jenl@auto-serv.com

    Thanks for your help!

    Jen

  • This should be posted in the T-SQL forum. Suggestions are for suggestions for SQL Server Central.com. Please repost there.

    I'd also include an example of what you have. There isn't a way to have this not included in a single query without making it horribly efficient. You can use an IF statement and if one param is null, then run a query without it, otherwise run the query with both parameters

    Steve Jones

    sjones@sqlservercentral.com

    http://www.sqlservercentral.com/columnists/sjones

    http://www.dkranch.net

Viewing 2 posts - 1 through 1 (of 1 total)

You must be logged in to reply to this topic. Login to reply