|
SELECT surname, name, stipend kurs, (stipend*kurs)/2; FROM Student
|
bet | 39/80 | Sana | 05.01.2024 | Hajmi | 281,59 Kb. | | #130407 |
Bog'liq 1-bob. Ma`lumotlar bazasining asosiy tushunchalari-fayllar.org
WHERE kurs = 4 AND stipend >0
Joylashtirilgan so`rovlar
Misol. Joylashtirilgan so`rov:
WHERE id_user IN (SELECT id_author FROM topics
WHERE topic_name='велосипедлар');
Misol. Xuddi shu so`rov:
SELECT name FROM users
WHERE id_user = (SELECT id_author FROM topics
WHERE topic_name='велосипедлар');
Moslashtirilgan so`rovda tashqi so`rov xar bir satri uchun ostki so`rov bajariladi
Misol:
SELECT *
FROM Customers outer
WHERE 10/03/1990 IN ( SELECT odate
FROM Orders inner
WHERE outer.cnum = inner.cnum );
Shu misol:
SELECT *
FROM Customers first, Orders second WHERE first.cnum = second.cnum AND second.odate = 10/03/1990; Misol.Tashqi so’rovdan foydalanish.
SELECT *
FROM Orders outer
WHERE amt > ( SELECT AVG amt
FROM Orders inter
WHERE inner.cnum = outer.cnum );
SQL da almashtirish funksiyalari bilan ishlash.
LOWER ()- berilgan satrni kichik harflarga almashtirib beradi.
UPPER () – kichik harflarni kata harflarga almashtirib beradi.
INIT CAP ()- satrdagi har bir so’z unlikni 1-harfini bosh harf qilib beradi.
Maslan, ularga quyidagi misolni ko’ramiz. SELECT LOWER (surname), UPPER (name) FROM Student
WHERE kurs=4 AND stipend 20;
LPAD(,uzunlikunlik,[ satr>);
Berilgan uzunlikunlikdagi qism satrni chapdan, o’ngga joylashtiriladi. Agar qism satr ko’rsatilmagan bo’lsa, satr sukut bilan, probellar bilan to’ldiriladi. Agar uzunlik o’nlik satr unlikdan kerak bo’lsa berilgan satr ko’rsatilgan uzunlikunlikgacha qirqiladi.
Misol:
|
| |