Firebird's CASE expression function

Source: Internet
Author: User
Tags expression new features

Ashamed to say, since the FB1.5 out, has not been in the deep excavation of its new features, but when it is an IB to treat a continuation-as long as the smooth transplant, even if OK.

Ashamed to say, since the FB1.5 out, has not been in the deep excavation of its new features, but when it is an IB to treat a continuation-as long as the smooth transplant, even if OK.
It was found in the first two days that the case expression was supported in Firebird 1.5.2. In my opinion, this is a fairly important feature in relational databases, because using case, you can generate a powerful PivotTable report-something that seems to have a special name in spreadsheets like Excel, forgetting what it is. But it's definitely a very useful feature. Of course, we can use spreadsheet software to achieve this function, but it will bring additional network communication burden, and its computational efficiency is much worse.
Here is an example of a perspective that is written using FB's demo database employee:

Select Cust_no
, sum (case when order_status = ' shipped ' then 1 else 0) as shipped
, sum (case when order_status = ' open ' then 1 else 0) as Open
, sum (case when order_status = ' waiting ' then 1 else 0) as waiting
From sales
GROUP BY Cust_no

It generates a result set that is sorted by the processing status of each customer's order.


Because using case, you can generate a powerful PivotTable report-something that seems to have a special name in a spreadsheet like Excel and forget what it is. But it's definitely a very useful feature. Of course, we can use spreadsheet software to achieve this function, but it will bring additional network communication burden, and its computational efficiency is much worse.
Here is an example of a perspective that is written using FB's demo database employee:

Select Cust_no
, sum (case when order_status = ' shipped ' then 1 else 0) as shipped
, sum (case when order_status = ' open ' then 1 else 0) as Open
, sum (case when order_status = ' waiting ' then 1 else 0) as waiting
From sales
GROUP BY Cust_no

It generates a result set that is sorted by the processing status of each customer's order.



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.