Git Product home page Git Product logo

patika-sql-odevler's Introduction

Patika-SQL-Odevler

Ödev 1

SELECT title, description
FROM film;

SELECT *
FROM film
WHERE length > 60 AND length < 75;

SELECT *
FROM film
WHERE rental_rate = 0.99 AND (replacement_cost = 12.99 OR replacement_cost = 28.99);

SELECT last_name
FROM customer
WHERE first_name = 'Mary';

SELECT *
FROM film
WHERE NOT (length > 50) AND NOT (rental_rate = 2.99 OR rental_rate = 4.99);

Ödev 2

SELECT *
FROM film
WHERE replacement_cost BETWEEN 12.99 AND 16.99;

SELECT first_name, last_name
FROM actor
WHERE first_name IN ('Penelope', 'Nick', 'Ed');

SELECT *
FROM film
WHERE rental_rate IN (0.99, 2.99, 4.99)
  AND replacement_cost IN (12.99, 15.99, 28.99);

Ödev 3

SELECT *
FROM country
WHERE country LIKE 'A%a';

SELECT *
FROM country
WHERE LENGTH(country) >= 6 AND country LIKE '%n';

SELECT *
FROM film
WHERE title ILIKE '%T%T%T%T%';

SELECT *
FROM film
WHERE title LIKE 'C%' AND LENGTH(title) > 90 AND rental_rate = 2.99;

Ödev 4

SELECT DISTINCT replacement_cost
FROM film;

SELECT COUNT(DISTINCT replacement_cost)
FROM film;

SELECT COUNT(*)
FROM film
WHERE title LIKE 'T%' AND rating = 'G';

SELECT COUNT(*)
FROM country
WHERE LENGTH(country) = 5;

SELECT COUNT(*)
FROM city
WHERE city ILIKE '%r';

Ödev 5

SELECT *
FROM film
WHERE title LIKE '%n'
ORDER BY length DESC
LIMIT 5;

SELECT *
FROM film
WHERE title LIKE '%n'
ORDER BY length ASC
OFFSET 5
LIMIT 5;

SELECT *
FROM customer
WHERE store_id = 1
ORDER BY last_name DESC
LIMIT 4;

Ödev 6

SELECT AVG(rental_rate) AS average_rental_rate
FROM film;

SELECT COUNT(*)
FROM film
WHERE title LIKE 'C%';

SELECT MAX(length) AS max_length
FROM film
WHERE rental_rate = 0.99;

SELECT COUNT(DISTINCT replacement_cost) AS distinct_replacement_costs
FROM film
WHERE length > 150;

Ödev 7

SELECT rating, COUNT(*) AS film_count
FROM film
GROUP BY rating;

SELECT replacement_cost, COUNT(*) AS film_count
FROM film
GROUP BY replacement_cost
HAVING COUNT(*) > 50
ORDER BY film_count DESC;

SELECT store_id, COUNT(*) AS customer_count
FROM customer
GROUP BY store_id;

SELECT country_id, COUNT(*) AS city_count
FROM city
GROUP BY country_id
ORDER BY city_count DESC
LIMIT 1;

Ödev 8

CREATE TABLE employee (
    id SERIAL PRIMARY KEY,
    name VARCHAR(50),
    birthday DATE,
    email VARCHAR(100)
);

INSERT INTO employee (name, birthday, email) VALUES
('John Doe', '1990-05-15', '[email protected]'),
('Jane Smith', '1988-09-21', '[email protected]'),
...
-- 50 adet benzeri kayıt

UPDATE employee SET name = 'New Name' WHERE id = 1;
UPDATE employee SET birthday = '1992-11-30' WHERE id = 2;
...
-- Diğer sütunlar için de benzer şekilde güncelleme

DELETE FROM employee WHERE id = 1;
DELETE FROM employee WHERE name = 'John Doe';
...
-- Diğer sütunlar için de benzer şekilde silme

Ödev 9

SELECT city.city, country.country
FROM city
INNER JOIN country ON city.country_id = country.country_id;

SELECT payment.payment_id, customer.first_name, customer.last_name
FROM customer
INNER JOIN payment ON customer.customer_id = payment.customer_id;

SELECT rental.rental_id, customer.first_name, customer.last_name
FROM customer
INNER JOIN rental ON customer.customer_id = rental.customer_id;

Ödev 10

SELECT city.city, country.country
FROM city
LEFT JOIN country ON city.country_id = country.country_id;

SELECT payment.payment_id, customer.first_name, customer.last_name
FROM customer
RIGHT JOIN payment ON customer.customer_id = payment.customer_id;

SELECT customer.first_name, customer.last_name, rental.rental_id
FROM customer
LEFT JOIN rental ON customer.customer_id = rental.customer_id

UNION ALL

SELECT customer.first_name, customer.last_name, rental.rental_id
FROM rental
LEFT JOIN customer ON rental.customer_id = customer.customer_id
WHERE customer.customer_id IS NULL;

Ödev 11

SELECT first_name FROM actor
UNION
SELECT first_name FROM customer;

SELECT first_name FROM actor
INTERSECT
SELECT first_name FROM customer;

SELECT first_name FROM actor
EXCEPT
SELECT first_name FROM customer;

-- Tüm verileri sıralama (tekrar edenleri gösterme)
SELECT first_name FROM actor
UNION ALL
SELECT first_name FROM customer;

-- Kesişen verileri sıralama
SELECT first_name FROM actor
INTERSECT ALL
SELECT first_name FROM customer;

-- İlk tabloda bulunan ancak ikinci tabloda bulunmayan verileri sıralama
SELECT first_name FROM actor
EXCEPT ALL
SELECT first_name FROM customer;

Ödev 12

SELECT COUNT(*) AS film_count
FROM film
WHERE length > (SELECT AVG(length) FROM film);

SELECT COUNT(*) AS film_count
FROM film
WHERE rental_rate = (SELECT MAX(rental_rate) FROM film);

SELECT *
FROM film
WHERE rental_rate = (SELECT MIN(rental_rate) FROM film)
AND replacement_cost = (SELECT MIN(replacement_cost) FROM film);

SELECT customer_id, COUNT(*) AS transaction_count
FROM payment
GROUP BY customer_id
ORDER BY COUNT(*) DESC;

patika-sql-odevler's People

Contributors

bpolat0 avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.