PostgreSQL Tasks:
Table I created table name is βmoviesβ
TASK 1 : Show details for Vijay acted movies.
SELECT * FROM movies WHERE actor=βvijayβ;
TASK 2 : Show Vijay movies names only.
SELECT movie FROM movies WHERE actor=βvijayβ;
TASK 3 : Show details, lokesh kanagaraj directed movie and actor name starts with βkβ and ends with vowels[a,e,i,o,u].
SELECT * FROM movies WHERE director=βlokesh kanagarajβ AND actor LIKE βk%β AND actor SIMILAR TO β%[aeiou]β;
TASK 4 : Show movie name only, lokesh kanagaraj directed movie and actor name starts with βkβ and ends with vowels[a,e,i,o,u].
SELECT movie FROM movies WHERE director=βlokesh kanagarajβ AND actor LIKE βk%β AND actor SIMILAR TO β%[aeiou]β;
TASK 5 : Show movie name and actor name only, lokesh kanagaraj directed movie and actor name starts with βkβ and ends with vowels[a,e,i,o,u].
SELECT movie,actor FROM movies WHERE director=βlokesh kanagarajβ AND actor LIKE βk%β AND actor SIMILAR TO β%[aeiou]β;
TASK 6 : Show the details, director name starts and ends with same letter.
SELECT * FROM movies WHERE LEFT(director, 1)=RIGHT(director, 1);
TASK 7 : Show the movie name only, the director name starts and ends with same letter.
SELECT movie FROM movies WHERE LEFT(director, 1)=RIGHT(director, 1);
TASK 8 : Show the director name only, the director name start and ends with same letter.
SELECT director FROM movies WHERE LEFT(director, 1)=RIGHT(director, 1);
TASK 9 : Show the movie name, the actors have only five character.
SELECT movie FROM movies WHERE LENGTH(actor)=5;
TASK 10 : Show the movie name and actors name, actors have only five character.
SELECT movie,actor FROM movies WHERE LENGTH(actor)=5;
TASK 11 : Add a column salary_in_crore and values.
ALTER TABLE movies ADD COLUMN salary_in_crore INT;
UPDATE movies SET salary_in_crore =100 WHERE actor = βvijayβ;
UPDATE movies SET salary_in_crore =70 WHERE actor = βkamalβ;
UPDATE movies SET salary_in_crore =90 WHERE actor = βajithβ;
UPDATE movies SET salary_in_crore =40 WHERE actor = βkarthiβ;
UPDATE movies SET salary_in_crore =110 WHERE actor = βrajiniβ;
UPDATE movies SET salary_in_crore =50 WHERE actor = βdhanushβ;
UPDATE movies SET salary_in_crore =5 WHERE actor = βsooriβ;
SELECT * FROM movies;
TASK 12 : Show actor name and salary,order by salary high to low.
SELECT actor, salary_in_crore FROM movies ORDER BY salary_in_crore DESC;
TASK 13 : Show top 3 actor based on salary.
SELECT DISTINCT actor, salary_in_crore FROM movies ORDER BY salary_in_crore DESC LIMIT 3;