| От | Mike Rylander |
|---|---|
| Тема | Re: How do i extract a certain bit from a bigint column |
| Дата | |
| Msg-id | 200405120817.39593.miker@purplefrog.com обсуждение |
| Ответ на | How do i extract a certain bit from a bigint column (Mats Sjöberg <mats.sjoberg@cybernetics.se>) |
| Ответы |
Re: How do i extract a certain bit from a bigint column
|
| Список | pgsql-sql |
On Wednesday 12 May 2004 07:05 am, Mats Sjöberg wrote: > Hello everyone > In a table i have a column status of type bigint. > I need to create a view of the table including all rows with bit 4 set > (value 8). > At the same time i need to exclude excludig all rows with bit 2 set. > > What is the syntax to extract those bits? > I have tested get_bit(string, offset) but this requires a string, and not a > bigint. > Is there a function to The easiest way is to test for a bit using bitwise and: SELECT * FROM table WHERE (status & 2::BIGINT) <> 0 AND (status & 8::BIGINT) = 0; -miker
В списке pgsql-sql по дате отправления:
Сайт использует файлы cookie для корректной работы и повышения удобства. Нажимая кнопку «Принять» или продолжая пользоваться сайтом, вы соглашаетесь на их использование в соответствии с Политикой в отношении обработки cookie ООО «ППГ», в том числе на передачу данных из файлов cookie сторонним статистическим и рекламным службам. Вы можете управлять настройками cookie через параметры вашего браузера