# SQL ขั้นสูงสำหรับ Data Engineering (Data Engineering) > Window functions, CTE แบบ recursive, การสืบค้นเชิงวิเคราะห์, การปรับแต่งประสิทธิภาพ, EXPLAIN ANALYZE, การทำดัชนี, การแบ่งพาร์ติชัน - 20 คำถามสัมภาษณ์ - Mid-Level - [คำถามสัมภาษณ์: Data Engineering](https://sharpskill.dev/th/technologies/data-engineering/interview-questions.md) ## 1. Window function ใดที่กำหนดหมายเลขลำดับที่ไม่ซ้ำให้กับแต่ละแถวภายในพาร์ติชัน? **คำตอบ** ROW_NUMBER() กำหนดหมายเลขลำดับที่ไม่ซ้ำให้กับแต่ละแถวภายในพาร์ติชัน โดยเริ่มจาก 1 ต่างจาก RANK() และ DENSE_RANK() ที่สามารถกำหนดหมายเลขเดียวกันให้กับค่าที่เท่ากัน ROW_NUMBER() รับประกันหมายเลขที่ไม่ซ้ำเสมอ แม้กระทั่งสำหรับค่าที่เหมือนกันในคำสั่ง ORDER BY ## 2. ความแตกต่างหลักระหว่าง RANK() และ DENSE_RANK() คืออะไร? **คำตอบ** RANK() เว้นช่องว่างในการนับหมายเลขหลังจากค่าที่เสมอกัน ตัวอย่างเช่น หากสองแถวได้อันดับ 1 แถวถัดไปจะได้อันดับ 3 DENSE_RANK() ไม่เว้นช่องว่าง: หลังจากสองแถวที่ได้อันดับ 1 แถวถัดไปจะได้อันดับ 2 ความแตกต่างนี้สำคัญสำหรับการวิเคราะห์การจัดอันดับที่ช่องว่างอาจทำให้สถิติผิดเพี้ยน ## 3. วิธีคำนวณยอดรวมสะสม (running total) ด้วย window function อย่างไร? **คำตอบ** SUM() OVER ที่มี ORDER BY และไม่มี frame ที่ชัดเจนจะใช้ ROWS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW เป็นค่าเริ่มต้น ซึ่งคำนวณผลรวมของแถวก่อนหน้าทั้งหมดจนถึงและรวมแถวปัจจุบัน นี่เป็นพฤติกรรมมาตรฐานสำหรับการสร้างยอดรวมสะสมในการวิเคราะห์อนุกรมเวลาหรือตามลำดับ ## มีอีก 17 คำถาม - บทบาทของคำสั่ง PARTITION BY ใน window function คืออะไร? - ฟังก์ชันใดที่อนุญาตให้เข้าถึงค่าของแถวก่อนหน้าใน window function? สมัครฟรี: https://sharpskill.dev/th/login ## หัวข้อสัมภาษณ์ Data Engineering อื่นๆ - [Linux & Shell - พื้นฐาน](https://sharpskill.dev/th/technologies/data-engineering/interview-questions/linux-shell-basics.md): 20 คำถาม, Junior - [Git & GitHub - พื้นฐาน](https://sharpskill.dev/th/technologies/data-engineering/interview-questions/git-github-fundamentals.md): 20 คำถาม, Junior - [Python ขั้นสูงสำหรับ Data Engineering](https://sharpskill.dev/th/technologies/data-engineering/interview-questions/python-advanced-de.md): 25 คำถาม, Junior - [Docker - พื้นฐาน](https://sharpskill.dev/th/technologies/data-engineering/interview-questions/docker-fundamentals.md): 25 คำถาม, Junior - [Google Cloud Platform - พื้นฐาน](https://sharpskill.dev/th/technologies/data-engineering/interview-questions/gcp-fundamentals.md): 20 คำถาม, Junior - [CI/CD และคุณภาพโค้ด](https://sharpskill.dev/th/technologies/data-engineering/interview-questions/ci-cd-code-quality.md): 20 คำถาม, Mid-Level - [Docker Compose](https://sharpskill.dev/th/technologies/data-engineering/interview-questions/docker-compose.md): 20 คำถาม, Mid-Level - [FastAPI - Data API](https://sharpskill.dev/th/technologies/data-engineering/interview-questions/fastapi.md): 20 คำถาม, Mid-Level - [Data Lake - สถาปัตยกรรมและการนำเข้าข้อมูล](https://sharpskill.dev/th/technologies/data-engineering/interview-questions/data-lake.md): 20 คำถาม, Mid-Level - [BigQuery สำหรับ Data Engineering](https://sharpskill.dev/th/technologies/data-engineering/interview-questions/bigquery-de.md): 20 คำถาม, Mid-Level - [PostgreSQL - การดูแลระบบ](https://sharpskill.dev/th/technologies/data-engineering/interview-questions/postgresql-admin.md): 20 คำถาม, Mid-Level - [Data Modeling สำหรับ Data Engineering](https://sharpskill.dev/th/technologies/data-engineering/interview-questions/data-modeling-de.md): 20 คำถาม, Mid-Level - [Fivetran & Airbyte - การนำเข้าข้อมูล](https://sharpskill.dev/th/technologies/data-engineering/interview-questions/fivetran-airbyte.md): 20 คำถาม, Mid-Level - [dbt - พื้นฐาน](https://sharpskill.dev/th/technologies/data-engineering/interview-questions/dbt-fundamentals-de.md): 20 คำถาม, Mid-Level - [Apache Airflow - พื้นฐาน](https://sharpskill.dev/th/technologies/data-engineering/interview-questions/airflow-fundamentals.md): 20 คำถาม, Mid-Level - [Kubernetes - พื้นฐาน](https://sharpskill.dev/th/technologies/data-engineering/interview-questions/kubernetes-fundamentals.md): 20 คำถาม, Mid-Level - [dbt - ฟีเจอร์ขั้นสูง](https://sharpskill.dev/th/technologies/data-engineering/interview-questions/dbt-advanced-de.md): 20 คำถาม, Senior - [รูปแบบ ETL / ELT / ETLT](https://sharpskill.dev/th/technologies/data-engineering/interview-questions/etl-elt-patterns.md): 20 คำถาม, Senior - [Apache Airflow - ขั้นสูง](https://sharpskill.dev/th/technologies/data-engineering/interview-questions/airflow-advanced.md): 20 คำถาม, Senior - [Airflow + dbt - การจัดการ Pipeline](https://sharpskill.dev/th/technologies/data-engineering/interview-questions/airflow-dbt-integration.md): 20 คำถาม, Senior - [PySpark - การประมวลผลขนาดใหญ่](https://sharpskill.dev/th/technologies/data-engineering/interview-questions/pyspark.md): 20 คำถาม, Senior - [Google Pub/Sub - การสตรีมข้อมูล](https://sharpskill.dev/th/technologies/data-engineering/interview-questions/pubsub-streaming.md): 20 คำถาม, Senior - [Apache Beam & Dataflow](https://sharpskill.dev/th/technologies/data-engineering/interview-questions/apache-beam-dataflow.md): 20 คำถาม, Senior - [Kubernetes - Production และ Scaling](https://sharpskill.dev/th/technologies/data-engineering/interview-questions/kubernetes-advanced.md): 20 คำถาม, Senior - [Terraform - Infrastructure as Code](https://sharpskill.dev/th/technologies/data-engineering/interview-questions/terraform.md): 20 คำถาม, Senior - [ฐานข้อมูล NoSQL](https://sharpskill.dev/th/technologies/data-engineering/interview-questions/nosql-databases.md): 20 คำถาม, Senior - [Data Architecture สมัยใหม่](https://sharpskill.dev/th/technologies/data-engineering/interview-questions/data-architecture.md): 20 คำถาม, Senior - [การมอนิเตอร์และการสังเกตการณ์](https://sharpskill.dev/th/technologies/data-engineering/interview-questions/monitoring-observability.md): 20 คำถาม, Senior - [IAM และความปลอดภัยของข้อมูล](https://sharpskill.dev/th/technologies/data-engineering/interview-questions/iam-security-de.md): 20 คำถาม, Senior --- Source: SharpSkill (https://sharpskill.dev), tech interview preparation for your real stack. HTML version of this page: https://sharpskill.dev/th/technologies/data-engineering/interview-questions/sql-advanced-de