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 Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Select with bitwise and 1

Status
Not open for further replies.

Jocsta

Programmer
Jun 14, 2002
204
GB
I am looking for a way to "mask" bits using an AND in a select statement, or equivalent.
I need to replicate a select statement we have on SQLServer, that strips of the top bits of a number and returns the max value without them e.g. :-

select max(cast(entity_id as bigint) & 0x0ffff) from entity;

Only keeping the bottom X bits of the value in the column, where the entity_id column is a "number(16,0)". I just cant find the way to do it in Oracle tho...

Thanks,
JOC

 
Check out the BITAND operator


In order to understand recursion, you must first understand recursion.
 
Thanks taupirho, that is exactly what I needed....
I had come across it while searching, but in all the examples I saw or it it was like "bitand(5,3) would return 1" etc, or it involved RAW stuff, so I (wrongly) assumed it was a PL/SQL thing and kinda discounted it without trying it.

I feel stupid now... thanks again.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top