Help with easy View

  • hi guys i am sorry for the ignorance but i am trying to do a view in sql server and i am trying to get the items that do not start with RA... i am trying like this but they keep coming out...

    HAVING      (MAX(Sales.Report_Date) >= CONVERT(DATETIME, '2006-01-01 00:00:00', 102)) AND

                          (NOT (Items.Item_No LIKE 'OS-*'))

     

     

     

  • It seems very easy to point this out probably becuase more information is needed

    It will be expected to be

    in the likes of item.item_name not like 'RA%'

    Again seems like more information is needed

    Mike

  • It's very simple. The wildcards in SQL SERVER are '%' (percent) for "any number of arbitrary characters" and '_' (underscore) for a single arbitrary character, not the '*' (asterisk) and the '.' (dot) used in Unix.

  • Where the item no doesn't start with RA, or some other field. I'm assuming the first. If it's another field you want to filter on, then replace Item_No with that other field.

    WHERE Items.Item_No NOT LIKE 'RA%'

    GROUP BY <your group by clause here>

    HAVING MAX(Sales.Report_Date) >= CONVERT(DATETIME, '2006-01-01 00:00:00', 102))

     

    Gail Shaw
    Microsoft Certified Master: SQL Server, MVP, M.Sc (Comp Sci)
    SQL In The Wild: Discussions on DB performance with occasional diversions into recoverability

    We walk in the dark places no others will enter
    We stand on the bridge and no one may pass

Viewing 4 posts - 1 through 3 (of 3 total)

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