How to Retrieve Records of any other Date IF Current Date Record is not present?

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Soniad
    New Member
    • Jan 2009
    • 66

    How to Retrieve Records of any other Date IF Current Date Record is not present?

    Hi,

    In my website, I show commodity details on daily basis.These details are stored in one table for each day.
    I select record by matching current date and current date records are displayed.but there me cases when some day details are not updated.
    Hence, I need query where if current date record is not there then it should fetch records of any other date for which record is present.
    I could do this by showing previous date record,But not necessary that previous date record is always present.

    Any Suggestion.

    Regards,
    "D"
  • Rabbit
    Recognized Expert MVP
    • Jan 2007
    • 12517

    #2
    Instead of matching on current date, you could match on MAX() date.

    Comment

    • Soniad
      New Member
      • Jan 2009
      • 66

      #3
      Hi Rabbit,

      Thanx.yes now it worked.By taking the last date in subquery.

      Code:
      Select * From Tbl Where DtDate = 
      (Select  Max(DtDate)  From Tbl)
      Order By ColID
      Regards,
      "D"

      Comment

      Working...