"Postgresql" Database functions

Source: Internet
Author: User
Tags postgresql

1.Postgresql SQL statements for several previous records

SELECT * FROM table where ... LIMIT N ;

2.SQL Limit integer Offset integer

: the need to query the middle data in a database is often used.

For example, the following SQL statement:

①select * from testtable limit 2,1;

②select * from testtable limit 2 offset 1;

Both are capable of accomplishing the need, but there is a difference between them:

① is a query starting from the third section of the database, taking a single piece of data, that is, the third piece of data

② is to start querying two data from the second data in the database, that is, the second and third articles.

3.distinct icd01 : The number of ICD01 values in the query table

Select distinct icd01, icd02 from Drug_icd a inner joins RCP_ICD10 D on a.icd=d.icd01 where cag<> ';

4.split_part (Text1,text2,integer) : A string from the Interger (starting at 1) position to the Text2 position (excluding the Text2 character) based on the Text2 split string Text1.

For example: Take the character before the first decimal point in the field icd01 the table ICD10

(Query results)

SQL statements: Select Split_part (icd01, '. ', 1) from ICD10;

5.Coalesce (SUM (value1), 0) : Equivalent to IsNull (num1,0) in SQL Server, non-null judgment

Postgresql Database functions

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.