In-memory database in the application of the column career, H2 in the column, HSQLDB in the column career

Source: Internet
Author: User

In fact, the list of career change is relatively simple with sum and decode function can be, but I encountered the project, do not know the data who design the field is also designed to be a long type, this long is different from Java, the long in Oracle refers to variable long binary data, the longest 2G, Alas, there is no way to convert.

The following is a conversion of hsqldb, which converts a long to a double type, where D.value is a long, and status is an int type, so value needs to be converted

SELECT P.name,p.id,

SUM (DECODE (D.k_name, ' a ', convert (d.value,sql_double), NULL)) as A1,

SUM (DECODE (D.k_name, ' a ', convert (d.value,sql_double), NULL)) as B1,

SUM (DECODE (D.k_name, ' a ', d.status,null)) as A1_status,

SUM (DECODE (D.k_name, ' a ', d.status,null)) as B1_status

From

P left JOIN

D on P.id=d.id

WHERE A in (' A ', ' B ')

GROUP by P.name,p.id

ORDER by Decode (a,null,0,a) DESC LIMIT 0,10

H2 is a memory database, similar to HSQLDB, but performance does not seem to be hsqldb stable

SELECT P.name,p.id,

SUM (DECODE (D.k_name, ' a ', convert (d.value,number), NULL)) as A1,

SUM (DECODE (D.k_name, ' a ', convert (d.value,number), NULL)) as B1,

SUM (DECODE (D.k_name, ' a ', d.status,null)) as A1_status,

SUM (DECODE (D.k_name, ' a ', d.status,null)) as B1_status

From

P left JOIN

D on P.id=d.id

WHERE A in (' A ', ' B ')

GROUP by P.name,p.id

ORDER by Decode (a,null,0,a) DESC LIMIT 0,10


This article is from the "effort Snail" blog, please make sure to keep this source http://newhouse2000.blog.51cto.com/4355310/1536108

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.