peri hoki perihoki clarustologistics rimashaop.com pola taktis menang gates of olympus x1000 perihoki pemain perihoki bongkar trik jepep starlight princess x1000 perihoki beri panduan lengkap bermain mahjong ways 2 pgsoft tips cara penghasil uang pgsoft mahjong ways 2 perihoki mahjong wins 3 perihoki memberikan penggali terbesar fenomena gates of olympus buka peluang besar bagi duta76 cara dapat pola emas rahasia di duta7 wild west gold trik menang pgsoft mahjong ways 2 modal receh maxwin duta76 duta76 main pgsoft mahjong ways 2 di sela istirahat scatter hitam mahjong wins 3 spin pasti jepe duta76 pola petir tersembunyi gates of olympus perihoki pgsoft perkuat mahjong ways 2 di akun perihoki perihoki beri pola jitu mahjong wins 3 auto maxwin 5 scatter jackpot driver ojol strategi satpam scatter mahjong strategi menang mahjong abc1131 scatter emas pabrik wonosobo modal tipis scatter jadi cuan rtp mahjong ways supir menang tukang cuci motor menemukan keberuntungan di mahjong
A PHP Error was encountered
Severity: Warning
Message: ini_set(): Headers already sent. You cannot change the session module's ini settings at this time
Filename: Session/Session.php
Line Number: 282
Backtrace:
File: /home/blogchuabenh/domains/freetuts.net/public_html/site/controllers/Main_controller.php
Line: 10
Function: __construct
File: /home/blogchuabenh/domains/freetuts.net/public_html/sources/index.php
Line: 299
Function: require_once
File: /home/blogchuabenh/domains/freetuts.net/public_html/index.php
Line: 26
Function: require_once
A PHP Error was encountered
Severity: Warning
Message: session_set_cookie_params(): Cannot change session cookie parameters when headers already sent
Filename: Session/Session.php
Line Number: 294
Backtrace:
File: /home/blogchuabenh/domains/freetuts.net/public_html/site/controllers/Main_controller.php
Line: 10
Function: __construct
File: /home/blogchuabenh/domains/freetuts.net/public_html/sources/index.php
Line: 299
Function: require_once
File: /home/blogchuabenh/domains/freetuts.net/public_html/index.php
Line: 26
Function: require_once
A PHP Error was encountered
Severity: Warning
Message: ini_set(): Headers already sent. You cannot change the session module's ini settings at this time
Filename: Session/Session.php
Line Number: 304
Backtrace:
File: /home/blogchuabenh/domains/freetuts.net/public_html/site/controllers/Main_controller.php
Line: 10
Function: __construct
File: /home/blogchuabenh/domains/freetuts.net/public_html/sources/index.php
Line: 299
Function: require_once
File: /home/blogchuabenh/domains/freetuts.net/public_html/index.php
Line: 26
Function: require_once
A PHP Error was encountered
Severity: Warning
Message: ini_set(): Headers already sent. You cannot change the session module's ini settings at this time
Filename: Session/Session.php
Line Number: 314
Backtrace:
File: /home/blogchuabenh/domains/freetuts.net/public_html/site/controllers/Main_controller.php
Line: 10
Function: __construct
File: /home/blogchuabenh/domains/freetuts.net/public_html/sources/index.php
Line: 299
Function: require_once
File: /home/blogchuabenh/domains/freetuts.net/public_html/index.php
Line: 26
Function: require_once
A PHP Error was encountered
Severity: Warning
Message: ini_set(): Headers already sent. You cannot change the session module's ini settings at this time
Filename: Session/Session.php
Line Number: 315
Backtrace:
File: /home/blogchuabenh/domains/freetuts.net/public_html/site/controllers/Main_controller.php
Line: 10
Function: __construct
File: /home/blogchuabenh/domains/freetuts.net/public_html/sources/index.php
Line: 299
Function: require_once
File: /home/blogchuabenh/domains/freetuts.net/public_html/index.php
Line: 26
Function: require_once
A PHP Error was encountered
Severity: Warning
Message: ini_set(): Headers already sent. You cannot change the session module's ini settings at this time
Filename: Session/Session.php
Line Number: 316
Backtrace:
File: /home/blogchuabenh/domains/freetuts.net/public_html/site/controllers/Main_controller.php
Line: 10
Function: __construct
File: /home/blogchuabenh/domains/freetuts.net/public_html/sources/index.php
Line: 299
Function: require_once
File: /home/blogchuabenh/domains/freetuts.net/public_html/index.php
Line: 26
Function: require_once
A PHP Error was encountered
Severity: Warning
Message: ini_set(): Headers already sent. You cannot change the session module's ini settings at this time
Filename: Session/Session.php
Line Number: 317
Backtrace:
File: /home/blogchuabenh/domains/freetuts.net/public_html/site/controllers/Main_controller.php
Line: 10
Function: __construct
File: /home/blogchuabenh/domains/freetuts.net/public_html/sources/index.php
Line: 299
Function: require_once
File: /home/blogchuabenh/domains/freetuts.net/public_html/index.php
Line: 26
Function: require_once
A PHP Error was encountered
Severity: Warning
Message: ini_set(): Headers already sent. You cannot change the session module's ini settings at this time
Filename: Session/Session.php
Line Number: 375
Backtrace:
File: /home/blogchuabenh/domains/freetuts.net/public_html/site/controllers/Main_controller.php
Line: 10
Function: __construct
File: /home/blogchuabenh/domains/freetuts.net/public_html/sources/index.php
Line: 299
Function: require_once
File: /home/blogchuabenh/domains/freetuts.net/public_html/index.php
Line: 26
Function: require_once
A PHP Error was encountered
Severity: Warning
Message: ini_set(): Headers already sent. You cannot change the session module's ini settings at this time
Filename: drivers/Session_files_driver.php
Line Number: 108
Backtrace:
File: /home/blogchuabenh/domains/freetuts.net/public_html/site/controllers/Main_controller.php
Line: 10
Function: __construct
File: /home/blogchuabenh/domains/freetuts.net/public_html/sources/index.php
Line: 299
Function: require_once
File: /home/blogchuabenh/domains/freetuts.net/public_html/index.php
Line: 26
Function: require_once
A PHP Error was encountered
Severity: Warning
Message: session_set_save_handler(): Cannot change save handler when headers already sent
Filename: Session/Session.php
Line Number: 110
Backtrace:
File: /home/blogchuabenh/domains/freetuts.net/public_html/site/controllers/Main_controller.php
Line: 10
Function: __construct
File: /home/blogchuabenh/domains/freetuts.net/public_html/sources/index.php
Line: 299
Function: require_once
File: /home/blogchuabenh/domains/freetuts.net/public_html/index.php
Line: 26
Function: require_once
A PHP Error was encountered
Severity: Warning
Message: session_start(): Cannot start session when headers already sent
Filename: Session/Session.php
Line Number: 143
Backtrace:
File: /home/blogchuabenh/domains/freetuts.net/public_html/site/controllers/Main_controller.php
Line: 10
Function: __construct
File: /home/blogchuabenh/domains/freetuts.net/public_html/sources/index.php
Line: 299
Function: require_once
File: /home/blogchuabenh/domains/freetuts.net/public_html/index.php
Line: 26
Function: require_once
Hàm CASE trong SQL Server - Freetuts
STRING FUNCTIONS
NUMERIC/MATH FUNCTIONS
DATE/TIME FUNCTIONS
CONVERSION FUNCTIONS
CONFIGURATION FUNCTIONS
ADVANCED FUNCTIONS
CÁC CHỦ ĐỀ
BÀI MỚI NHẤT
Hàm CASE trong SQL Server
Trong bài này mình sẽ hướng dẫn cách sử dụng câu lệnh CASE
trong SQL Server
thông qua cú pháp và ví dụ thực tế.
Bài viết này được đăng tại freetuts.net , không được copy dưới mọi hình thức.
1. Mô tả
Câu lệnh CASE
có chức năng của câu lệnh IF-THEN-ELSE
.
2. Cú pháp
Cú pháp cho câu lệnh CASE
trong SQL Server
(Transact-SQL) là:
CASE expression
WHEN value_1 THEN result_1
WHEN value_2 THEN result_2
...
WHEN value_n THEN result_n
ELSE result
END
Hoặc
Bài viết này được đăng tại [free tuts .net]
CASE
WHEN condition_1 THEN result_1
WHEN condition_2 THEN result_2
...
WHEN condition_n THEN result_n
ELSE result
END
Trong đó:
expression
: Biểu thức sẽ được so sánh với từng giá trị được cung cấp. (ví dụ: value_1, value_2, ... value_n).
value_1, value_2, ... value_n
: Các giá trị sẽ được sử dụng trong đánh giá. Các giá trị được đánh giá theo thứ tự được liệt kê. Khi một giá trị khớp với biểu thức, câu lệnh CASE sẽ thực thi các câu lệnh tương ứng và không đánh giá thêm nữa.
condition_1, condition_2, ... condition_n
: Các điều kiện sẽ được đánh giá. Các điều kiện được đánh giá theo thứ tự được liệt kê. Khi một điều kiện được xác định là đúng, câu lệnh CASE
sẽ trả về kết quả và không đánh giá các điều kiện nữa. Tất cả các điều kiện phải là cùng một kiểu dữ liệu.
result_1, result_2, ... result_n
: Giá trị được trả về sau khi một điều kiện được tìm thấy là đúng. Tất cả các giá trị phải là cùng một kiểu dữ liệu.
Lưu ý:
Nếu không tìm thấy giá trị / điều kiện nào là TRUE, thì câu lệnh CASE
sẽ trả về giá trị trong mệnh đề ELSE.
Nếu mệnh đề ELSE bị bỏ qua và không có điều kiện nào được tìm thấy là đúng, thì câu lệnh CASE
sẽ trả về NULL.
Điều kiện được đánh giá theo thứ tự được liệt kê. Khi một điều kiện được xác định là đúng, câu lệnh CASE
sẽ trả về kết quả và không đánh giá các điều kiện nữa.
3. Version
Câu lệnh CASE
có thể được sử dụng trong các phiên bản sau của SQL Server
(Transact-SQL):
SQL Server 2017, SQL Server 2016, SQL Server 2014, SQL Server 2012, SQL Server 2008 R2, SQL Server 2008, SQL Server 2005
4. Ví dụ
SELECT
CASE
WHEN diem < 7 THEN 'duoi kha'
WHEN diem = 7 THEN 'kha'
WHEN diem > 7 THEN 'tren kha'
END
FROM diem;
Cùng chuyên mục: