Błąd funkcji round

0

Cześć. Napisałem już prawie wszystko odnośnie zapytania, które wyciągnie mi datę urodzenia z pesel-u osób oraz policzy różnicę (tzn. ile dni minęło od urodzenia do dnia dzisiejszego, a także w prosty sposób policzy mi na tej podstawie wiek osoby poprzez proste podzielenie ilości dni przez 365.
W tym momencie zaczynają się schody bo wynik chcę następnie zaokrąglić stosując funkcję round, ale dostaję taki komunikat:

screenshot-20210407221405.png

Samo zapytanie wygląda następująco:

select S.REKA_PESEL, S.REKA_DATURODZ,
       substring(S.REKA_PESEL from 5 for 2) || '.' || substring(S.REKA_PESEL from 3 for 2) || '.' || '19' || substring(S.REKA_PESEL from 1 for 2) as DATA_URODZENIA,
       cast (substring(S.REKA_PESEL from 5 for 2) || '.' || substring(S.REKA_PESEL from 3 for 2) || '.' || '19' || substring(S.REKA_PESEL from 1 for 2) as date) as konwersja,
       cast ('Today' as date) as dzis,
       cast ('Today' as date) - cast (substring(S.REKA_PESEL from 5 for 2) || '.' || substring(S.REKA_PESEL from 3 for 2) || '.' || '19' || substring(S.REKA_PESEL from 1 for 2) as date) as roznica,
       (cast ('Today' as date) - cast (substring(S.REKA_PESEL from 5 for 2) || '.' || substring(S.REKA_PESEL from 3 for 2) || '.' || '19' || substring(S.REKA_PESEL from 1 for 2) as date)) / 365 as wiek,
       round (((cast ('Today' as date) - cast (substring(S.REKA_PESEL from 5 for 2) || '.' || substring(S.REKA_PESEL from 3 for 2) || '.' || '19' || substring(S.REKA_PESEL from 1 for 2) as date)) / 365),0)
from KD_REJ_KADRY S
where S.REKA_PESEL <> '';

Do momentu wpisania ostatniej linijki z round , tj.:

select S.REKA_PESEL, S.REKA_DATURODZ,
       substring(S.REKA_PESEL from 5 for 2) || '.' || substring(S.REKA_PESEL from 3 for 2) || '.' || '19' || substring(S.REKA_PESEL from 1 for 2) as DATA_URODZENIA,
       cast (substring(S.REKA_PESEL from 5 for 2) || '.' || substring(S.REKA_PESEL from 3 for 2) || '.' || '19' || substring(S.REKA_PESEL from 1 for 2) as date) as konwersja,
       cast ('Today' as date) as dzis,
       cast ('Today' as date) - cast (substring(S.REKA_PESEL from 5 for 2) || '.' || substring(S.REKA_PESEL from 3 for 2) || '.' || '19' || substring(S.REKA_PESEL from 1 for 2) as date) as roznica,
       (cast ('Today' as date) - cast (substring(S.REKA_PESEL from 5 for 2) || '.' || substring(S.REKA_PESEL from 3 for 2) || '.' || '19' || substring(S.REKA_PESEL from 1 for 2) as date)) / 365 as wiek
from KD_REJ_KADRY S
where S.REKA_PESEL <> '';

wykonuje się prawidłowo, bo mam takie wyniki:
screenshot-20210407222326.png

Proszę o pomoc w określeniu co jest nie tak w linijce z funkcją round.

1

Konwertuj na liczbę, przed zaokrągleniem bo wygląda, że tam jakiś czas dostajesz.

0
BlackBad napisał(a):

Konwertuj na liczbę, przed zaokrągleniem bo wygląda, że tam jakiś czas dostajesz.

Tak zrobiłem. Przekonwertowalem na typ numeric i już jest ok.

1 użytkowników online, w tym zalogowanych: 0, gości: 1