0

I'm sorry for my title, but it's totally right. I don't know PostgreSQL well, but I have to take over other person's application. I know SQL, so it's usually no problem to take over any application based on MSSQL, Oracle, MySQL, PostgreSQL, ... but here is some kind of PostgreSQL facet. Could anyone, please, explain this query to me?

select company_generate_course_template_fc
       ((select company_id from company order by 1 desc limit 1)::int)

2 Answers 2

2

The query calls the function company_generate_course_template_fc() passing the result of the query: select company_id from company order by 1 desc limit 1 as an argument. The result is cast to an integer using ::int (see the manual for details)

Apart from the ::int part (and the different ways of limiting the result to a single row), this wouldn't be much different in other databases

The ANSI SQL equivalent of ::int would be cast(... as integer)

Sign up to request clarification or add additional context in comments.

1 Comment

I'm sorry, I think I was so stupid because of early morning :-[... When I've got another look at the query, I knew. Thank you again and I'm sorry for this question.
0

If you are talking about ::int it's type casting from string (company_id) to integer value

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.