Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7530979
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T05:03:41+00:00 2026-05-30T05:03:41+00:00

I never worked with pgsql before and im trying to convert this function to

  • 0

I never worked with pgsql before and im trying to convert this function to Mysql… can you give me a hand?

create or replace function hot(ups integer, downs integer, date timestamp with time zone) returns numeric as $$
select round(cast(log(greatest(abs($1 - $2), 1)) + sign($1 - $2) * (date_part('epoch', $3) - 1134028003) / 45000.0 as numeric), 7) $$ language sql immutable

EDIT:

So far i’ve got this but it still gives me an error

create function hot(ups MEDIUMINT, downs MEDIUMINT, date timestamp) returns BIGINT
select round(cast(log(greatest(abs($1 - $2), 1)) + sign($1 - $2) * (unix_timestamp(date) - 1134028003) / 45000.0 BIGINT), 7)
$$ language sql immutable

“You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ‘BIGINT), 7) $$ language sql immutable’ at line 2”

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-30T05:03:42+00:00Added an answer on May 30, 2026 at 5:03 am

    That defines the function hot(ups, downs, date) (where ups and downs are integers and date is a timestamp-with-time-zone) as this SQL statement:

    SELECT ROUND( CAST( LOG(GREATEST(ABS(ups - downs), 1))
                        + SIGN(ups - downs) * (DATE_PART('epoch', date) - 1134028003) / 45000.0
                        AS NUMERIC
                      ),
                  7
                )
    ;
    

    The $$ ... $$ notation is a PostgreSQL notation for a multiline string (in this case, containing the SQL query that defines the function). The LANGUAGE SQL indicates that the function is in SQL (and not, for example, PL/pgSQL). The IMMUTABLE (see http://www.postgresql.org/docs/8.4/static/sql-createfunction.html) indicates that the function doesn’t modify the database, and always returns the same results for the same arguments. (In other words, it’s a “pure” function.)

    • For information on round, log, abs, and sign, see http://www.postgresql.org/docs/8.4/static/functions-math.html.
    • CAST(... AS NUMERIC) returns its argument as a number (for example, CAST('123' AS NUMERIC) is 123).
    • For information on greatest, see http://www.postgresql.org/docs/8.4/static/functions-conditional.html.
    • DATE_PART('epoch', ...) returns its argument (a date) as a number of seconds since 1970-01-01 00:00:00.000 GMT.
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

First, this has never worked before, so it is not specifically related to VS
I've never worked with any version control systems before. Now I'm trying to learn
never worked with .net before so please excuse me if this sounds stupid. On
I know you can return a javascript view but this has never worked for
I've never worked with curl before so I'm trying to just set up something
I have never worked with json before. I am trying: http://api.worldbank.org//topics?format=JSON and make things
I have never worked with web services and rails, and obviously this is something
I've never worked with the registry before and it seems a bit intimidating, as
I have inherited a SSIS project. I have never worked with SSIS before, and
I have just arrived at new company and have never worked with Qt before,

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.