======================================================================
 DB::Handy SQL Cheat Sheet                                 [UZ] O'zbek
======================================================================

[ Data Types (Ma'lumotlar turlari) ]
  INT          : Butun son (Integer)
  FLOAT        : O'nlik son (Floating point)
  VARCHAR(n)   : O'zgaruvchan uzunlikdagi matn (Maksimal n bayt)
  CHAR(n)      : Qat'iy uzunlikdagi matn (Har doim n bayt)

[ 1. CREATE / DROP (Jadval yaratish va o'chirish) ]
  CREATE TABLE student (id INT PRIMARY KEY, name VARCHAR(20), score INT);
  DROP TABLE student;

[ 2. INSERT (Ma'lumot qo'shish) ]
  -- Ustunlarni belgilab ma'lumot qo'shish (Tavsiya etiladi)
  INSERT INTO student (id, name, score) VALUES (1, 'Alice', 85);
  -- Ustunlarni belgilamasdan ma'lumot qo'shish
  INSERT INTO student VALUES (2, 'Bob', 70);

[ 3. SELECT (Ma'lumotlarni qidirish) ]
  -- Barcha ma'lumotlarni olish
  SELECT * FROM student;
  -- Shart belgilash (WHERE)
  SELECT name, score FROM student WHERE score >= 80;
  -- Saralash (ORDER BY)
  SELECT * FROM student ORDER BY score DESC;
  -- Qatorlar sonini cheklash (LIMIT)
  SELECT * FROM student ORDER BY score DESC LIMIT 3;

[ 4. UPDATE (Ma'lumotlarni yangilash) ]
  UPDATE student SET score = 90 WHERE id = 1;

[ 5. DELETE (Ma'lumotlarni o'chirish) ]
  DELETE FROM student WHERE id = 2;

[ Operators (Operatorlar) ]
  Taqqoslash: =, <>, !=, >, <, >=, <=
  Oraliq    : BETWEEN 70 AND 90
  Ro'yxat   : IN (1, 2, 3) yoki NOT IN (1, 2, 3)
  Matn      : LIKE 'A%' (A bilan boshlanadi), LIKE '%A' (A bilan tugaydi)
  NULL tekshiruvi: IS NULL, IS NOT NULL
  Mantiqiy  : AND, OR, NOT

[ Aggregate Functions (Agregat funksiyalar) ]
  COUNT(*) : Qatorlarni sanash
  SUM(col) : Yig'indini hisoblash
  AVG(col) : O'rtacha qiymatni hisoblash
  MAX(col) : Eng katta qiymatni topish
  MIN(col) : Eng kichik qiymatni topish
  (Misol) SELECT COUNT(*), AVG(score) FROM student;

[ Indexes (Indekslar yordamida tezlashtirish) ]
  CREATE INDEX idx_score ON student (score);
  CREATE UNIQUE INDEX uq_name ON student (name);
======================================================================
