Link to home
Create AccountLog in
Avatar of pepps11976
pepps11976

asked on

SQL Query

Hi all i have a query within SQL and would like to return values in a column where the first three letters are AMC and AMW,

How do i add this to my query

Thanks

John
ASKER CERTIFIED SOLUTION
Avatar of Guy Hengel [angelIII / a3]
Guy Hengel [angelIII / a3]
Flag of Luxembourg image

Link to home
membership
Create an account to see this answer
Signing up is free. No credit card required.
Create Account
Do you mean the columns have the first 3 letters AMC and AMW or the contents of the columns have that?

A bit more info if you could and I'll see what help I can provide.

Lee
Avatar of pepps11976
pepps11976

ASKER

Ok

This is my query

SELECT     TOP (100) PERCENT dbo.ihead.ih_account, dbo.ihead.ih_name, dbo.ihead.ih_quodate, dbo.ihead.ih_invdate, dbo.ihead.ih_quotat, dbo.ihead.ih_invoice,
                      dbo.ihead.ih_exvat, dbo.ihead.ih_vat, dbo.ihead.ih_fcurr, dbo.ihead.ih_region, dbo.ihead.ih_terrtry, dbo.ihead.ih_raised, dbo.itran.it_anal, dbo.itran.it_status,
                      dbo.itran.it_recno
FROM         dbo.ihead LEFT OUTER JOIN
                      dbo.itran ON dbo.ihead.ih_doc = dbo.itran.it_doc
WHERE     (dbo.ihead.ih_quotat > ' ') AND (dbo.itran.it_recno = '1') AND (dbo.itran.it_status = 'A') AND (dbo.itran.it_anal > ' ') AND (dbo.ihead.ih_quotat > ' ') AND (DATEPART(m,
                      dbo.ihead.ih_quodate) = DATEPART(m, GETDATE())) AND (DATEPART(yyyy, dbo.ihead.ih_quodate) = DATEPART(yyyy, GETDATE()))

In the column IT_anal i need to retrieve everything that starts with AMW and AMC

angelIII i tried you code and it returned nothing there should be 12 entries

where left(myfield, 3) in ('AMC', 'AMW')

so mine worked correctly?!
Sorry yes i mistyped the query sorry :(