Not in Select Statement


I need to specify in the select statement that the USER_1 field is not equal to 'STD'.

I tried first putting it in the where clause but get an error stating that the multipart statement could not be identified.

How can I specify this in the following select statement?

more ▼

asked Aug 07, 2012 at 12:54 AM in Default

avatar image

1.4k 100 114 121

Can you please share the full code. It is a bit difficult to help with such less information.

Aug 07, 2012 at 10:53 AM Usman Butt
(comments are locked)
10|1200 characters needed characters left

1 answer: sort voted first

It looks like you have two different questions. The first, how to ensure USER_1 is not equal to 'STD' you do this:

 SELECT tn.*
 FROM dbo.TableName AS tn
 WHERE tn.USER_1 != 'STD'

Obviously I have substituted a table where yours would go.

You can't filter data in the SELECT clause. That is what the WHERE clause is for. If you're getting an error that the name doesn't exist, it suggests that you may have a problem in the code elsewhere.

The second question is around the MAX statement. You will have to make that a part of a GROUP BY query for it to work.

more ▼

answered Aug 07, 2012 at 12:11 PM

avatar image

Grant Fritchey ♦♦
137k 20 47 81

(comments are locked)
10|1200 characters needed characters left
Your answer
toggle preview:

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here



Answers and Comments

SQL Server Central

Need long-form SQL discussion? SQLserverCentral.com is the place.



asked: Aug 07, 2012 at 12:54 AM

Seen: 571 times

Last Updated: Aug 07, 2012 at 01:01 PM

Copyright 2018 Redgate Software. Privacy Policy