> For the complete documentation index, see [llms.txt](https://docs.layraweb.com.tr/merhaba/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.layraweb.com.tr/merhaba/sql-tarafi/konular/sorgulamalar/case.md).

# CASE

SQL "CASE" ifadesi, verilerin belirli bir şart karşılığında farklı değerler döndürmesini sağlar. Bu, verilerin sorgulanması ve dönüştürülmesi sırasında kullanılabilecek dinamik bir yapı sunar.

Aşağıdaki genel yapı, SQL CASE ifadesinin nasıl kullanılabileceğini gösterir:

```sql
CASE 
WHEN condition THEN result 
WHEN condition THEN result 
... 
ELSE result 
END
```

* `CASE`: CASE ifadesinin başlangıç noktasıdır.
* `WHEN`: Belirli bir şartı belirtir. Eğer bu şart doğru ise, o takdirde sonuç döndürülür.
* `THEN`: Bir şart doğru olduğunda döndürülecek sonucu belirtir.
* `ELSE`: Tüm şartlar doğru değilse döndürülecek sonucu belirtir.
* `END`: CASE ifadesinin son noktasıdır.

Aşağıdaki örnek, bir müşterinin "customer\_status" sütununun değerine göre müşterinin durumunu belirleyen bir sorgu gösterir:

```sql
SELECT customer_name, 
       customer_status, 
       CASE 
           WHEN customer_status = 'active' THEN 'Aktif' 
           WHEN customer_status = 'inactive' THEN 'Pasif' 
           ELSE 'Bilinmiyor' 
       END AS customer_status_text 
FROM customers;
```

Bu örnekte, `customer_status` sütununun değeri "active" ise, müşterinin durumu "Aktif", "inactive" ise "Pasif" olarak döndürülür. Eğer hiçbir şart doğru değilse, müşterinin durumu "Bilinmiyor" olarak döndürülür.


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.layraweb.com.tr/merhaba/sql-tarafi/konular/sorgulamalar/case.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
