Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Selecting by case 3

Status
Not open for further replies.

jorbroni

Technical User
Dec 5, 2002
24
US

I have two types of transactions, one are "a" type transactions and the others are "A" type transactions. The "a" type transactions are the ones I want to select but I dont know how to select by case.

Can anyone help me?


 
It sounds like you should to put this in the WHERE clause:
Code:
WHERE Transaction = 'a'


Dan.
 
WHERE LOWER(Transaction) = 'a'

Just in case the ignore case property is turned on, otherwise the query will look for 'a' and 'A'.

Tim
 
Double check that Tim's suggestion gives you the proper results.

LOWER - converts uppercase character data to lowercase.

So it converts what is in the parenthesis to lowercase. I.E. LOWER(Transaction) means all data in the Transaction column will be returned as LOWER case.

Let's say you have this in Transaction:

A
B
a
b

LOWER(Transaction) will return:
a
b
a
b

Try it:

SELECT LOWER(Transaction)

So, Tim's query should return EVERYTHING with either a lowercase a or an uppercase A.

-SQLBill
 
Cast to a varbinary

Code:
WHERE Cast(Transaction as varbinary) = Cast('a' as varbinary)

select Cast('a' as varbinary), Cast('A' as varbinary)
produces the following result

0x61	0x41


"Shoot Me! Shoot Me NOW!!!"
- Daffy Duck
 
Good point SQLBill. Just call that a slight brain fart on my part. Yes, my suggestion will probably not help you get the results you want.

Tim
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top