-
Notifications
You must be signed in to change notification settings - Fork 0
/
fetch.sql
25 lines (21 loc) · 834 Bytes
/
fetch.sql
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
-- database yaratish
CREATE DATABASE customer_db;
-- databasega ulanish
\c customer_db
-- table yaratish
CREATE TABLE IF NOT EXISTS customer (
id SERIAL PRIMARY KEY,
first_name TEXT NOT NULL,
last_name TEXT NOT NULL,
email TEXT NOT NULL
);
-- tablega ma'lumot yozish
INSERT INTO customer(first_name, last_name, email)
VALUES ('Xasan', 'Nosirov', '[email protected]'),
('Ahrorbek', 'Alijonov', '[email protected]'),
('Anvarjon', 'Shavqiyev', '[email protected]');
-- FETCH
SELECT first_name, last_name FROM customer ORDER BY email FETCH FIRST ROW ONLY;
SELECT last_name, email FROM customer ORDER BY email FETCH FIRST 1 ROW ONLY;
SELECT last_name FROM customer ORDER BY email FETCH FIRST 4 ROW ONLY;
SELECT first_name, last_name FROM customer ORDER BY email OFFSET 5 ROWS FETCH FIRST 5 ROW ONLY;