Re: string functions and operators

Поиск
Список
Период
Сортировка
От Petru Ghita
Тема Re: string functions and operators
Дата
Msg-id 4BA8229E.70108@venaver.info
обсуждение исходный текст
Ответ на Re: string functions and operators  (Petru Ghita <petrutz@venaver.info>)
Ответы Re: string functions and operators  (Neil Stlyz <neilstylz@yahoo.com>)
Список pgsql-sql
-----BEGIN PGP SIGNED MESSAGE----- <br /> Hash: SHA1 <br />  <br /> For numeric data types use:<br /><br /><a
class="moz-txt-link-freetext"
href="http://www.postgresql.org/docs/8.4/static/functions-math.html">http://www.postgresql.org/docs/8.4/static/functions-math.html</a><br
/><br/> You could then use|floor|(dp or numeric)|| for example:<br /><br /> postgres=# select floor(71.912);<br />
 floor<br/> - -------<br />     71<br /> (1 row)<br /><br /> postgres=# select 71.912-floor(71.912);<br />  ?column?<br
/>- ----------<br />     0.912<br /><br /><br /> But as you might have negative numbers in there I guess you should<br
/>abs() the values like in:<br /><br /> postgres=# select abs(71.912)-floor(abs(71.912));<br />  ?column?<br /> -
----------<br/>     0.912<br /><br /><br /> postgres=# select abs(-171.912)-floor(abs(-171.912));<br />  ?column?<br />
-----------<br />     0.912<br /> (1 row)<br /><br /><br /><br /><br /><br /><br /> On 23/03/2010 2:50, Petru Ghita
wrote:<br/><span style="white-space: pre;">> That field of yours... what type is it? Is it TEXT? is it a numeric<br
/>> type? If it's TEXT, why don't you make it say... NUMERIC(/10/,<br /> > /6///)?<br /> > <br /> > <a
class="moz-txt-link-freetext"
href="http://www.postgresql.org/docs/8.4/interactive/datatype-numeric.html#DATATYPE-NUMERIC-DECIMAL">http://www.postgresql.org/docs/8.4/interactive/datatype-numeric.html#DATATYPE-NUMERIC-DECIMAL</a><br
/>><br /> ><br /> ><br /> > </span><br /> On 23/03/2010 2:20, Neil Stlyz wrote:<br /><span
style="white-space:pre;">>> Hello,<br /> > <br /> > <br /> > <br /> >> I have a dilema and I was
hopingsomeone here may offer guidance<br /> > <br /> >> or assistance. I bet this is a very simple question
forsomeone<br /> > <br /> >> out there but I am having problems coming up with a solution.<br /> > Here<br
/>> <br /> >> it is...<br /> > <br /> > <br /> > <br /> >> suppose I have a field with the
followingvalues:<br /> > <br /> > <br /> > <br /> >> 77.1 77.2 134.1 134.2 134.3 5.1 5.2<br /> > <br
/>> <br /> > <br /> >> I need two seperate SELECT queries. One would return the<br /> > following<br />
><br /> >> values (everything left of the decimal point)<br /> > <br /> > <br /> > <br /> >> 77
77134 134 5 5<br /> > <br /> > <br /> > <br /> >> The second query would return all of the values to the
rightof<br /> > <br /> >> the decimal point:<br /> > <br /> > <br /> > <br /> >> 1 2 1 2 3 1
2<br/> > <br /> > <br /> > <br /> > <br /> > <br /> >> Now, I have been using the following
information(although very<br /> > <br /> >> Greek) to try to solve this problem:<br /> > <br /> > <br />
><br /> > <br /> > <a class="moz-txt-link-freetext"
href="http://www.postgresql.org/docs/current/static/functions-string.html">http://www.postgresql.org/docs/current/static/functions-string.html</a><br
/>><br /> ><br /> ><br /> ><br /> >  And I have been playing around with the syntax of the following:<br
/>> <br /> > <br /> > <br /> >> substring('112.5' from '%#"___.#"_' for '#')<br /> > <br /> > <br
/>> <br /> >> but the aforementioned is not quite working out... can someone<br /> > <br /> >> please
showme a string function that will produce the desired<br /> > <br /> >> results?<br /> > <br /> > <br
/>> <br /> >> Thanks! ~n<br /> > <br /> > <br /> > <br /> > </span><br /> -----BEGIN PGP
SIGNATURE-----<br /> Version: GnuPG v1.4.9 (MingW32) <br /> Comment: Using GnuPG with Mozilla - <a
class="moz-txt-link-freetext"href="http://enigmail.mozdev.org/">http://enigmail.mozdev.org/</a><br />  <br />
iEYEARECAAYFAkuoIp4ACgkQt6IL6XzynQQ9igCfRjfOhKXjYZ4gaP3b/4qYqswb<br /> qXMAoJcXbdB3BvCSJ7QH2PwAPMZpAdib <br /> =OY7b
<br/> -----END PGP SIGNATURE----- <br /><br /> 

В списке pgsql-sql по дате отправления:

Предыдущее
От: Petru Ghita
Дата:
Сообщение: Re: string functions and operators
Следующее
От: Neil Stlyz
Дата:
Сообщение: Re: string functions and operators