Eugenics - SQL

April 2, 2018 | Author: SaravananIfs | Category: Information Retrieval, Data Management, Technology, Computing, Computer Data


Comments



Description

--------------------------------------------------------------------------------------------------------------------------<<<<<<<<< SESSION 1 >>>>>>>>>>> --------------------------------------------------------------------------------------------------------------------------1. Write a query to create role table. Sample Query: create table role (id BIGINT(20), name varchar(255) NOT NULL, primary key(id)); CREATE TABLE role ( Id BIGINT(20), name VARCHAR(255) NOT NULL, PRIMARY KEY(Id) ); 2. Write a query to create skill table. Please note that the field description can be NULL and the default value is NULL. CREATE TABLE skill ( Id BIGINT(20) PRIMARY KEY, descriptiON VARCHAR(255) NULL, name VARCHAR(255) NOT NULL ); 3. Write a query to create post_type table. CREATE TABLE post_type ( Id BIGINT(20) PRIMARY KEY, name VARCHAR(255) NOT NULL ); 4. Write a query to create department table. CREATE TABLE department ( Id BIGINT(20) PRIMARY KEY, name VARCHAR(255) NOT NULL ); 5. Write a query to create degree table. CREATE TABLE degree ( Id BIGINT(20) PRIMARY KEY, department_id BIGINT(20) NOT NULL, name VARCHAR(255) NOT NULL, FOREIGN KEY(department_id) REFERENCES department(Id) ); 6. Write a query to create profile table. Please note that designation field can be NULL and the default value is NULL. CREATE TABLE profile ( Id BIGINT(20) PRIMARY KEY, address VARCHAR(255) NOT NULL, batch VARCHAR(255) NOT NULL, degree_id BIGINT(20) NOT NULL, designaton VARCHAR(255) NULL, gender VARCHAR(255) NOT NULL, FOREIGN KEY(degree_id) REFERENCES degree(Id) ); 7. Write a query to create higher_degree table. Please note that fields degree_name and university_name can be NULL and the default value is NULL. CREATE TABLE higher_degree ( Id BIGINT(20) PRIMARY KEY, degree_name VARCHAR(255) NULL, university_name VARCHAR(255) NULL, profile_id BIGINT(20) NOT NULL, FOREIGN KEY(profile_id) REFERENCES profile(Id) ); 8. Write a query to create experience table. Please note that filed end can be NULL and Default value is NULL. CREATE TABLE experience ( Id BIGINT(20)PRIMARY KEY, company_name VARCHAR(255) NOT NULL, current BIT(1) NOT NULL, end DATETIME NULL, start DATETIME NOT NULL, profile_id BIGINT(20) NOT NULL, FOREIGN KEY(profile_id) REFERENCES profile(Id) ); 9. Write a query to create project table. Please note that field short_description can be NULL and the default value is NULL. CREATE TABLE project ( Id BIGINT(20) PRIMARY KEY, name VARCHAR(255) NOT NULL, cONtent VARCHAR(255) NOT NULL. FOREIGN KEY(type_id) REFERENCES post_type(Id). name VARCHAR(255) NOT NULL. ALTER TABLE role ADD descriptiON VARCHAR(255). type_id BIGINT(20) NOT NULL. username VARCHAR(255) NOT NULL. CREATE TABLE post ( Id BIGINT(20)PRIMARY KEY. Write a query to create query table. Please note that field parent_id can be NULL and the default value is NULL. FOREIGN KEY(user_id) REFERENCES user(Id) ). ALTER TABLE role RENAME roles. Please note that the field profile_id can be NULL and the default value is NULL. Write a query to rename table roles to role. descriptiON VARCHAR(255) NULL. date DATETIME NOT NULL. 16. ALTER TABLE role DROP COLUMN descriptiON. user_id BIGINT(20)NOT NULL. Write a query to create event table. date DATETIME NOT NULL. FOREIGN KEY(profile_id) REFERENCES profile(Id) ). Write a query to create user table. FOREIGN KEY(profile_id) REFERENCES profile(Id). phONenumber VARCHAR(255) NOT NULL. date DATETIME NOT NULL. short_descriptiON VARCHAR(255) NULL. CREATE TABLE event ( Id BIGINT(20)PRIMARY KEY.number_of_members INT(11) NOT NULL. CREATE TABLE profile_skills ( skill_id BIGINT(20). 15. organiser_id BIGINT(20)NOT NULL. 14. profile_id BIGINT(20) NULL. parent_id BIGINT(20) NULL. 13. password VARCHAR(255) NOT NULL. cONtent VARCHAR(255) NOT NULL. profile_id BIGINT(20). profile_id BIGINT(20) NOT NULL. FOREIGN KEY(parent_id) REFERENCES query(Id). 17. role_id BIGINT(20) NOT NULL. emailid VARCHAR(255) NOT NULL. 10. PRIMARY KEY(skill_id. FOREIGN KEY(user_id) REFERENCES user(Id) ). FOREIGN KEY(role_id) REFERENCES role(Id) ). invitatiON VARCHAR(255) NOT NULL. ALTER TABLE role MODIFY COLUMN descriptiON VARCHAR(500). 19. FOREIGN KEY(organiser_id) REFERENCES user(Id) ). 12. Write a query to add a new column named description of type varchar(255) to role table. Write a query to rename table role to roles. user_id BIGINT(20) NOT NULL. CREATE TABLE user ( Id BIGINT(20) PRIMARY KEY. name VARCHAR(255) NOT NULL. CREATE TABLE query ( Id BIGINT(20) PRIMARY KEY. Please note that field description can be NULL and the default value is NULL. Write a query to create post table. 18. Write a query to remove the column description from the role table. Write a query to change the type of field description in the role table to varchar(500). 11. . ALTER TABLE roles RENAME role.profile_id) ). Write a query to create profile_skills table. INSERT INTO degree(id.20. 11. INSERT INTO project(id. Write a query to rename table department to departments. 3. 22. (2.role_id.current. --------------------------------------------------------------------------------------------------------------------------<<<<<<<<< SESSION 2 >>>>>>>>>>> --------------------------------------------------------------------------------------------------------------------------- INSERT INTO experience(id.'Anna University'. Write a query to insert any 2 records into the role table.username) VALUES(1.parent_id.'ECE'). Write a query to add a new column named user_id of type BIGINT(20) to department table.degree_name. 4. Write a query to insert any 2 records into the degree table. Write a query to insert any 2 records into the experience table.47.start.name) VALUES(1.'Anna University'. INSERT INTO role(id.profile_id) VALUES(1.1.'Female').address.044.'abcd@efgh.'technical skills'. DROP TABLE profile_skills. ALTER TABLE department DROP COLUMN user_id.name) VALUES(1.'efgh'. (2. INSERT INTO user(id. 7.user_id) .university_name. Write a query to insert any 2 records into the profile table. 1. (2. Write a query to insert any 2 records into the project table.name) VALUES(1.'coding').'ijkl'. (2. Write a query to insert any 2 records into the query table.'2015-11-11 13:23:44'. INSERT INTO skill(id. 10.'mnop'.'business'). Write a query to delete post table.phONenumber. Write a query to drop the column user_id from the department table.'Male'). INSERT INTO profile(id. 9. 8. user_id is a foreign key and it references id in the user table.'HR'.10. 23. 5. (2.gender) VALUES(1. INSERT INTO query(id.company_name.'designer').'Chennai'.designaton. Write a query to insert any 2 records into the department table.name.'For'.cONtent. Write a query to insert any 2 records into the skill table.'CTS'.profile_id. (2.batch. 21.045.1.'CTS'.016). Write a query to insert any 2 records into the user table. Write a query to insert any 2 records into the higher_degree table.password.name) VALUES(1.05. DROP TABLE post. Write a query to add a constraint to the department table.11.degree_id.emailid.'guide').'self learning'.'LONdON'.017. (2.department_id.'2008-11-11 13:23:44'.end.name) VALUES(1.'business').017).short_descriptiON) VALUES(1.profile_id) VALUES(1. ALTER TABLE department ADD user_id BIGINT(20).'bpo'). (2.'BE'. 24. 2. INSERT INTO department(id.017).date.9845621745.016.04.016).'for school AND college').descriptiON.'abcd'. ALTER TABLE department ADD FOREIGN KEY(user_id) REFERENCES user(Id).'2008-11-11 13:23:44'.'abcdefgh').'Library management'.number_of_members.017.'Manager'. Write a query to delete the table profile_skills.com'.profile_id.'learn').'IT').'ijklmnop').com'.'2015-11-11 13:23:44'.name. ALTER TABLE department RENAME departments. INSERT INTO higher_degree(id.'BE'.46.'ijkl@mnop.'for school AND college'). (2. INSERT INTO post_type(id.'En'. (2. 6.'Alumini management'. 25.9884642005. Write a query to insert any 2 records into the post_type table.'EEE').016. 79. Write a query to change the day by 1 of all dates in the query table on 31st Jan 2013. DELETE FROM skill WHERE name='Web Design'.456). 25) The event 'ALUMNI MEET' has been postponed by 3 hours.'2008-11-11 13:23:44'. DELETE FROM query WHERE date BETWEEN DATE_FORMAT(date.'2008-11-11 13:23:44'. UPDATE profile SET batch='1998' WHERE batch='98'. --------------------------------------------------------------------------------------------------------------------------<<<<<<<<< SESSION 3 >>>>>>>>>>> --------------------------------------------------------------------------------------------------------------------------- DELETE FROM post_type WHERE name='Technology'. (2. 21 Write a query to update the year in the date entry in the query table from 2012 to 2013.45).'2011-%m-%d').'Alumni meet'. INSERT INTO event(id. Write a query to change the skill name 'CAD' to 'CADCAM'. UPDATE post_type SET name='Technology' WHERE name='Tech'.'2008-11-11 13:23:44'.'2008-11-11 13:23:44'.user_id) VALUES(1.'2008-11-11 13:23:44'.name. Write a query to insert any 2 records into the event table. sorted by name in ascending order.INTERVAL 3 HOUR) WHERE name='ALUMNI MEET'.date. Write a query to change the role name 'Admin' to 'Administrator' UPDATE role SET name='Administrator' WHERE name='Admin'. UPDATE role SET name='Administrator' WHERE name='Admin'.organiser_id) VALUES(1. INSERT INTO post(id.'Library management'. 24) Write a query such that the experience table contains only the details regarding the current experience of the alumni. 15 Delete the role 'Student'. (2. Write a query to insert any 2 records into the post table. 13.'2012-%m-%d') .'OBA'. 23) Write a query to delete all queries from the query table posted before year 2012. Write a query to change the event time.456).46). UPDATE event SET date=DATE_ADD(date. SELECT * .'member'.'Library opening'.'Alumni meet'. UPDATE query SET date=DATE_FORMAT(date.INTERVAL 1 DAY) WHERE DATE(date)='2013-01-31'. DELETE FROM experience WHERE end is not null. Write a query to display the entire contents of the role table. 18 Write a query to change the post_type 'Tech' to 'Technology'. (2.'ManikANDan'.'Narayanan'. 1.cONtent.'Alumini management'.date. 14.123).descriptiON. You have correctly set the date now. 19 Write a query to delete the post_type 'Technology'.invitatiON.'Library opening'.78. DELETE FROM role WHERE name='Student'.123).987. 12.type_id. But you want to change all the date entries made on that day. 17 Write a query to delete the skill 'Web Design'. UPDATE query SET date=DATE_ADD(date.'0000-%m-%d') AND DATE_FORMAT(date.789. 16. 20 Write a query to change the batch name from 98 to 1998. UPDATE skill SET name='CADCAM' WHERE name='CAD'.'2013-%m-%d') WHERE date=DATE_FORMAT(date. 22) Accidentally the server date was set to a wrong value for 1 day.VALUES(1.'2008-11-11 13:23:44'. sorted by skill name. sorted in ascending order. Write a query to display the entire contents of the skill table. Write a query to display the entire contents of the department table. 4. 6.FROM role ORDER BY name. Write a query to display the names of all departments. . SELECT name.experience WHERE designaton='PROJECT MANAGER' AND current=1 ORDER BY batch. sorted in ascending order. Write a query to display the entire contents of the post_type table. sorted in ascending order. SELECT name FROM post_type ORDER BY name. sorted by name in descending order. SELECT DISTINCT designaton FROM profile ORDER BY designaton. 7. Write a query to display the names of all post types. sorted in ascending order based on address. 11. sorted in ascending order. SELECT * FROM post_type ORDER BY name DESC. sorted in ascending order based on name. Write a query to display the batch details of all alumni who are currently project managers. Write a query to display all unique designations from the profile table sorted in ascending order. SELECT * FROM skill ORDER BY name. 9. 14.descriptiON FROM skill ORDER BY name. SELECT DISTINCT designaton FROM profile WHERE batch=2008 AND gender='FEMALE' ORDER BY designaton. sorted by name in descending order. Write a query to display all designations of Female students/alumni from batch 2008 from the profile table sorted in ascending order. 2. sorted by name in ascending order. 3. SELECT DISTINCT designaton FROM profile WHERE gender='MALE' ORDER BY designaton. Write a query to display the names of companies in which the college alumni have been or are employees. SELECT name FROM role ORDER BY name. 10. SELECT address FROM profile WHERE gender='MALE' AND batch=2008 ORDER BY address. SELECT DISTINCT batch FROM profile. Write a query to display all designations of Male students/alumni from the profile table sorted in ascending order. Write a query to display the address details of Male alumni from 2008 batch. 15. 5. Write a query to display the names of all universities in which the alumni from this college have done or are doing their higher studies. 12. 8. Write a query to display all role names. SELECT * FROM department ORDER BY name DESC. SELECT DISTINCT university_name FROM higher_degree ORDER BY university_name. Write a query to display the names and descriptions of all skills. SELECT name FROM department ORDER BY name. 13. sorted in ascending order. sorted in descending order by date. sorted in ascending order by name. Give an alias to the number of skills as skill_count. Give an alias to the number of roles as role_count. sorted in ascending order by name. Write a query to display the content of all posts. sorrted in ascending order by name. SELECT name.phONenumber FROM user ORDER BY name. 3) Write a query to display the number of users who have not filled their profile yet. --------------------------------------------------------------------------------------------------------------------------<<<<<<<<< SESSION 4 >>>>>>>>>>> --------------------------------------------------------------------------------------------------------------------------1) Write a query to display the number of roles in the role table. 20. Write a query to display the content of all posts posted in January. SELECT DISTINCT company_name FROM experience WHERE current=1 ORDER BY company_name DESC. 16. SELECT name. Write a query to display the user name and password of Ram. Write a query to display the names of companies in which the college alumni are employees at present. 25.m. SELECT cONtent FROM query WHERE YEAR(date)='2013' ORDER BY date DESC. 22. sorted in descending order by date. SELECT cONtent FROM post WHERE date>'2014-01' ORDER BY date DESC. Write a query to display the names. SELECT cONtent FROM post ORDER BY date DESC. Give an alias to the number of users as user_count. Write a query to display the contents of all queries posted in year 2013.emailid. sorted in descending order by date. Write a query to display the names and phone numbers of all users. 2) Write a query to display the number of skills in the skill table.password FROM user WHERE name='RAM'. Write a query to display the names of all events scheduled in January 27. 21. 24. 17. SELECT name FROM event WHERE date='2014-01-27 15:00:00. SELECT name. Write a query to display the names and descriptions of all events scheduled on 27th January. emailids and phone numbers of all users.descriptiON FROM event WHERE date>'2014-01-27' ORDER BY name. 2014.short_descriptiON FROM project WHERE number_of_members>10 ORDER BY name. SELECT username.SELECT DISTINCT company_name FROM experience ORDER BY company_name. sorted by name in ascending order. sorted in descending order based on name. 19. SELECT COUNT(name) AS skill_count FROM skill. SELECT COUNT(name) AS user_count . 2014 at 3 p. sorted in descending order by name. SELECT COUNT(name) AS role_count FROM role.phONenumber FROM user ORDER BY name DESC. 18.0' ORDER BY name. SELECT name. Write a query to display the names and descriptions of projects with more than 10 members. 2014. 23. 12. SELECT COUNT(designaton) AS PM_count FROM profile WHERE designaton='PROJECT MANAGER'. 11. SELECT batch. Give an alias as project_count. 8) Write a query to display the batch name and the number of female alumni from each batch who have registered in the system. SELECT COUNT(*) AS project_count FROM project . 6) Write a query to display the batch name and the number of alumni from each batch who have registered in the system. 10. Give an alias as designaton_count. Write a query to display the batch of the seniormost alumni woking as 'Project Manager'. 9) Write a query to display the number of unique designatons in the profile table. 15) Write a query to display the name of the company and the number of alumni who are currently working in each company. Give an alias to the number of female alumni from each batch as female_alumni_count. SELECT batch. Give an alias as alumni_2008_count. SELECT designaton. 13) Write a query to display the designaton and the number of users who are currently working in each designaton. sorted by batch name. Give an alias as alumni_male_2008_count. 4) Write a query to display the number of alumni from 2008 batch who have registered in the system. Give an alias as Junior_PM_Batch.FROM user WHERE profile_id IS NULL. COUNT(*) AS alumni_count FROM experience WHERE current=1 GROUP BY company_name. SELECT MIN(BATCH) AS Senior_PM_Batch FROM profile WHERE designaton='PROJECT MANAGER'. SELECT COUNT(DISTINCT(designaton)) AS designaton_count FROM profile. Give an alias as designaton_count. SELECT company_name. Give an alias to the number of alumni from each batch as alumni_count. Give an alias to the number of alumni as alumni_count. sorted by designaton. Give an alias as company_count. COUNT(id) AS alumni_count FROM profile GROUP BY batch.COUNT(id) AS male_alumni_count FROM profile WHERE gender='MALE' GROUP BY batch. 5) Write a query to display the number of male alumni from 2008 batch who have registered in the system. 7) Write a query to display the batch name and the number of male alumni from each batch who have registered in the system. sorted by batch name.COUNT(designaton) AS designaton_count FROM profile GROUP BY designaton . SELECT batch. 14) Write a query to display the number of companies in which the college alumni are currently working in. SELECT MAX(BATCH) AS Junior_PM_Batch FROM profile WHERE designaton='PROJECT MANAGER'. Write a query to display the number of users who are currently working as 'Project Manager's. Write a query to display the batch of the juniormost alumni woking as 'Project Manager'. SELECT COUNT(*) AS company_count FROM experience WHERE current=1. SELECT COUNT(batch) AS alumni_2008_count FROM profile WHERE batch='2008'. Give an alias to the number of male alumni from each batch as male_alumni_count. SELECT COUNT(id) AS alumni_male_2008_count FROM profile WHERE batch='2008' AND gender='MALE'. 16) Write a query to display the number of projects in which the team size is more than 10. Give an alias as Senior_PM_Batch.COUNT(id) AS female_alumni_count FROM profile WHERE gender='FEMALE' GROUP BY batch. Give an alias as PM_Count.sorted by batch name. COUNT(*) AS number_of_events FROM event GROUP BY YEAR(date) . Give an alias as int_value. sorted by month.23. SELECT floor(1. 19) Write a query to display the number of posts posted in January 2014. 25) Write a query to display the name of the month and the number of events scheduled in each month in the year 2013.23. SELECT cONv('f'. WHERE DATE(date)>'2013-12-01'.23. SELECT COUNT(*) AS number_of_posts FROM post WHERE date>'2014-01'. --------------------------------------------------------------------------------------------------------------------------<<<<<<<<< SESSION 5 >>>>>>>>>>> --------------------------------------------------------------------------------------------------------------------------- 20) Write a query to display the number of queries raised / answered between 1 a.16. Give an alias as absolute.WHERE number_of_members>10. 4) Write a query to display the smallest integer value not less than -1.. 5) Write a query to convert a base 16 number 'F' to a base-2 number. SELECT MONTHNAME(date) AS month_name. Give an alias to the month name as month_name and the to the number of events scheduled as number_of_events. 17) Write a query to display the number of events that were scheduled for the year 2013. 3) Write a query to display the smallest integer value not less than 1. SELECT COUNT(*) AS number_of_queries FROM query WHERE TIME(date) BETWEEN '01:00' AND '05:00'.m and 5 a.23.m (both inclusive). SELECT COUNT(*) AS number_of_events FROM event WHERE DATE(date)='2014-01-27' . Give an alias as number_of_events. Give an alias as number_of_posts. Give an alias as int_value. Give an alias as number_of_events.23) as int_value. 24) Write a query to display the year and the number of events scheduled in each year. Give an alias as number_of_events. 2013. 1) Write a query to display the absolute value of 2. Give an alias as base2.. SELECT COUNT(*) AS number_of_posts FROM post 7) Write a query to display the largest integer value not greater than -1. 6) Write a query to display the largest integer value not greater than 1. Give an alias as number_of_events. Name of the month must be displayed as January. 2013.COUNT(*) as number_of_events FROM event WHERE YEAR(date)='2013' GROUP BY MONTH(date). Give an alias as number_of_queries. 2014. February . SELECT ceil(-1. SELECT year(date) . 23) Write a query to display the number of posts posted after 1st December. 2) Write a query to display the absolute value of -32. SELECT ceil(1. 21) Write a query to display the number of events that were scheduled on 27th January. 18) Write a query to display the year and the number of events scheduled in each year. Give an alias as . 22) Write a query to display the number of posts posted before 1st December.COUNT(year(date)) AS number_of_events FROM event GROUP BY year(date). SELECT COUNT(*) AS number_of_events FROM event WHERE year(date)=2013. Give an alias as number_of_posts. sorted by year. Give an alias as number_of_posts. sorted by year.2) as base2. SELECT YEAR(date).23) as int_value. SELECT COUNT(*) AS number_of_posts FROM post WHERE DATE(date)<'2013-12-01'. SELECT abs(-32) as absolute. SELECT abs(2). Give an alias as int_value.23) as int_value. SELECT floor(-1. SELECT weekday('2014-03-01') AS weekday_index. 2014. 15. SELECT name. SELECT name. 5. SELECT name. Write a query to display the names of users in a 30 character length field by left padding with ?. 12. 2. 2014.'?') AS modified_name FROM user ORDER BY name. Write a query to display the names of users that end with aa. sorted by the name of the user.2) AS start_2_chars FROM user ORDER BY name. Write a query to display the names of the users and the last 2 characters of the names of all users. Write a query to display the names of the users and the names of users with leading and trailing space characters removed.LEFT(name. Write a query to display the names of all users in lowercase.length(name) AS length FROM user ORDER BY name. 7.RTRIM(name) AS modified_name FROM user ORDER BY name. sorted by the name of the user. Write a query to display the name of the user(s) having the longest name. 10) Write a query to return the day name of the date 1st March. --------------------------------------------------------------------------------------------------------------------------<<<<<<<<< SESSION 6 >>>>>>>>>>> --------------------------------------------------------------------------------------------------------------------------1. sorted by the name of the user. Write a query to display the names of users in a 30 character length field by right padding with ?. sorted by the name of the user.RIGHT(name. SELECT name FROM user WHERE length(password)<3 ORDER BY name. Give an alias to the first 2 characers as start_2_chars. Give an alias as modified_name. Give an alias as weekday_name. 10. SELECT name FROM user WHERE name LIKE '%aa' ORDER BY name. 8.30. SELECT name. SELECT dayname('2014-03-01') AS weekday_name. 9. Use the inbuilt function length(). sorted by the name of the user. . Give an alias as round_value. Give an alias as lower_case. 8) Write a query to round off 1.int_value. sorted by name. Write a query to display the names of all users in uppercase. sorted by the name of the user. SELECT LPAD(name. 3. SELECT name FROM user WHERE name LIKE 'a%a'. Write a query to display the name of the users and the length of the names of the users. 11. 9) Write a query to return the weekday index of the date 1st March. sorted by the name of the user. sorted by name. Give an alias to the first 2 characers as last_2_chars. Write a query to display the names of all users that start and end with letter a. sorted by the name of the user. Give an alias as modified_name.2) AS last_2_chars FROM user ORDER BY name. Give an alias as modified_name. Write a query to display the names of the users and the names of users with trailing space characters removed. SELECT RPAD(name. SELECT round(1. Give an alias as modified_name. SELECT UPPER(name) AS upper_case FROM user ORDER BY name.30.'?') AS modified_name FROM user ORDER BY name.RTRIM(LTRIM(name)) AS modified_name FROM user ORDER BY name. Give an alias to the length of the name as length. 4. Write a query to display the names of users that contain 'aa'. Give an alias as upper_case. 6. SELECT LOWER(name) AS lower_case FROM user ORDER BY name. sorted by the name of the user. Give an alias as modified_name.LTRIM(name) AS modified_name FROM user ORDER BY name. sorted by the name of the user. sorted by the name of the user. Write a query to display the names of the users and the first 2 characters of the names of all users. Write a query to display the name of the user(s) who have set a password of less than 3 characters. SELECT name.298 to one decimal place. SELECT name From user WHERE length(name) IN (SELECT MAX(length(name )) FROM user ).23) as int_value. 14. SELECT name. sorted by the name of the user. Write a query to display the names of the users and the names of users with leading space characters removed.1) as round_value. 13. Hint : Use the function weekday.298. Give an alias as weekday_index. user.experience.* FROM role INNER JOIN user ON role.name FROM user INNER JOIN role ON user.profile_id WHERE role.'Alumni') .company_name.*.profile_id WHERE role.name ASC.name='Alumni' ORDER BY user.*. experience.company_name FROM user left JOIN role ON user.profile_id WHERE user.id JOIN experience ON profile. user.experience.company_name FROM user JOIN role ON user.name FROM user JOIN role ON user.skill. designaton and the currently working company name of 'Ram'. SELECT role.name ASC. emailid.name='Ram' AND experience.name ASC.name.id left JOIN profile ON user.role_id ORDER BY role. sorted by name and then by company name.skill.role_id ORDER BY role. 2) Write a query to display the entire contents of the table after performing a left join on role table and user table. SELECT name FROM user WHERE name LIKE 'P%' AND LENGTH(name)=6 ORDER BY name. sorted by name and then by skillset name. 4) Write a query to display the phone number.experience.designaton.name. 5) Write a query to display the name and skillset name of all alumni users (role .name.id=experience. .name='Alumni' ORDER BY user. 6) Write a query to display the name and all company names in which they have worked of all alumni users(role .id=user. SELECT user. 7) Write a query to display the name and all company names in which they have worked of all alumni users(role .id left JOIN experience ON profile.id JOIN department ON degree. SELECT user.profile_id=profile.name='Alumni' ORDER BY user.'Alumni'). department.current=1.role_id=role. sorted by role name and then by name of the user.name. sorted by name.'Alumni') who have been employed or are employed. SELECT user.id=experience.id WHERE role. user.profile_id JOIN skill ON profile_skills. user. batch.id ORDER BY user.experience. Write a query to display all 6-letter names that start with P and end with a.role_id=role.department. sorted by role name and then by name of the user.id=profile_skills.id JOIN profile ON user.id=user.id JOIN profile ON user.emailid. 16.name. SELECT user.name. sorted by name and then by company name.name.profile_id=profile.id JOIN degree ON profile.name ASC.profile. sorted by name of the user.degree_id=degree.id=experience. SELECT user.name.role_id=role.user.profile_id=profile. SELECT role.name.* FROM role LEFT JOIN user ON role.phonenumber.id JOIN profile_skills ON profile.company_name FROM user JOIN profile ON user.batch.role.role_id=role.id JOIN experience ON profile.skill_id=skill. --------------------------------------------------------------------------------------------------------------------------<<<<<<<<< SESSION 7 >>>>>>>>>>> --------------------------------------------------------------------------------------------------------------------------1) Write a query to display the entire contents of the table after performing an inner join on role table and user table.profile_id=profile.department_id=department.name ASC. (Include users who have never been employed also). 3) Write a query to display the user name and role of all users.company_name.profile.SELECT name FROM user WHERE name LIKE '%aa%' ORDER BY name. current=1 ORDER BY user.name='Alumni' AND user.emailid.profile_id WHERE role.experience.name.name='Alumni' AND department. email id.phonenumber. sorted by name.name. email id.'Alumni') who have done higher studies in other colleges / universities and the University(s) in which the user has done higher studies.phonenumber. phone number and address of all alumni(role .user. SELECT user.user.id JOIN profile ON user.id=experience.user.id WHERE role.user.id JOIN degree ON profile.degree_id=degree.name 13) Write a query to display the name.'Alumni') from 2008.emailid.emailid. sorted by name and then by University.emailid. [Include users who are currently working only] SELECT user. SELECT user.profile.user.id WHERE role.name='Alumni' AND profile.name 9) Write a query to display the name and the company name in which they are currently working of all alumni users(role . SELECT user. sorted by name.experience. SELECT user.id JOIN degree ON profile.(Include alumni users who are currently working only). sorted by name of the user.profile_id=profile.user.profile_id=profile.address FROM user JOIN role ON user.profile.name. phone number and address of all alumni(role .user.address FROM user JOIN role ON user.name='Alumni' AND experience.name.name 12) Write a query to display the name.'Alumni') users from 2008 batch.name 11) Write a query to display the name.id JOIN department ON degree.batch='2008' ORDER BY user.profile_id is not null ORDER BY user.phonenumber.university_name FROM user INNER JOIN role ON user. sorted by name.profile_id=profile.role_id=role. phone number and address of all alumni(role .role_id=role.'Alumni') users who have filled in their profile.id JOIN profile ON user.phonenumber. email id.company_name FROM user JOIN role ON user.id WHERE role.user.name.name='CSE' ORDER BY user.company_name FROM user JOIN role ON user.name.profile.id JOIN experience ON profile.name='Alumni' AND higher_degree.id JOIN experience ON profile.id=experience.name='Alumni' AND experience.id INNER JOIN higher_degree ON profile.id JOIN profile ON user.address FROM user JOIN role ON user.id JOIN profile ON user.id WHERE role.id INNER JOIN profile ON user. SELECT user.name='BSC_CT' ORDER BY user.role_id=role.profile_id=profile. email id.profile_id=profile.profile_id WHERE role.higher_degree.'Alumni').name.name 14) Write a query to display the name of the alumni users(role .profile_id=profile.profile.role_id=role.profile_id=profile.degree_name is not null .role_id=role.name='Alumni' AND degree.profile_id WHERE role.name 10) Write a query to display the name.current=1 AND profile. SELECT user.id JOIN profile ON user.id=higher_degree.'Alumni') users from 'CSE' department.degree_id=degree.batch='2008' ORDER BY user.role_id=role.address FROM user JOIN role ON user. sorted by name.department_id=department.8) Write a query to display the name and the company name in which they are working of all alumni users(role .id JOIN profile ON user. sorted by name. phone number and address of all alumni(role .'Alumni') users from 'BSC_CT'.role_id=role. id INNER JOIN higher_degree ON profile.department.id INNER JOIN profile ON user.name.name='Alumni' AND department.higher_degree.university_name .id JOIN profile ON user.id JOIN department ON degree.id WHERE role.name='Alumni' AND profile.id ORDER BY degree.batch FROM user JOIN role ON user.name. email id.batch.department_id=department. batch.profile.name.name.university_name='Texas University' ORDER BY user.role_id=role. SELECT user.emailid.department_id=department. batch and degree of all female alumni users(role 'Alumni'). SELECT user.name.profile.designaton FROM user .university_name . SELECT user.gender='female' ORDER BY user.degree. SELECT degree.role_id=role. 21) Write a query to display the name and designaton of all male alumni users(role 'Alumni').user.gender='female' ORDER BY user. 16) Write a query to display the names.name.id=higher_degree. sorted by name of the user.degree_id=degree. SELECT user.name.id WHERE role.name.profile.profile_id INNER JOIN degree ON profile.name='Alumni' AND profile.address FROM user JOIN role ON user.batch.name FROM degree INNER JOIN department ON degree.profile_id=profile.gender='female' ORDER BY user.name 19) Write a query to display the name.department_id=department.profile_id WHERE role.id JOIN profile ON user. sorted by name.GROUP BY user.id JOIN degree ON profile. SELECT user. sorted by name. sorted in order.higher_degree.profile_id=profile.id JOIN profile ON user.id JOIN department ON degree.name='Alumni' AND higher_degree.department_id=department.name FROM user JOIN role ON user.id JOIN profile ON user.profile.profile_id=profile. sorted by name and then by University.profile.user.id WHERE role.name FROM user JOIN role ON user.'Alumni').'Alumni') who have done their higher studies in 'Texas University'. sorted by degree name.degree_id=degree.degree_name is not null GROUP BY user.degree_id=degree.id=higher_degree. sorted by name.profile_id=profile.id WHERE role. degree and department of all female alumni users(role .role_id=role.name.name.profile_id=profile.higher_degree.role_id=role.name='Alumni' AND profile.'Alumni') from 'CSE' department who have done higher studies in other colleges / universities and the University(s) in which the user has done higher studies.id INNER JOIN higher_degree ON profile.name. 15) Write a query to display the name of the alumni users(role .role_id=role.name='CSE' AND higher_degree.name 18) Write a query to display the name.university_name FROM user INNER JOIN role ON user.id JOIN degree ON profile.name 20) Write a query to display all degree names and the department offering the degree.id JOIN degree ON profile. SELECT user.name 17) Write a query to display the name and batch of all female alumni users(role . phone number and address of all alumni users (role .department.degree.phonenumber.id JOIN department ON degree.degree_id=degree.'Alumni'). post date and then by post content. SELECT user.name.content FROM user INNER JOIN query ON user.name='Alumni' experience.event.name='Programming' ORDER BY user.'Alumni') who are currently working in TCS.date(date). sorted by name and then by date.date.user_id INNER JOIN post_type ON post.skill_id=skill.name FROM user JOIN role ON user.id JOIN profile ON user. 22) Write a query to display the name and designaton of all alumni users(role .profile.user_id WHERE parent_id is not null ORDER BY name.JOIN role ON user.id=query.name. 28) Write a query to display the name and department of users who have good 'Programming' skills.date(date).date)='2013' ORDER BY user.content.id=query.company_name='TCS' ORDER BY user.post.name.id=post.name ORDER BY user.post.id JOIN profile ON user.name.name.profile_id=profile. SELECT user.type_id=post_type.name.current=1 AND 23) Write a query to display the names of the users who have raised or answered queries and the content of the queries. 26) Write a query to display the names of the users who have posted 'Technology' related posts and the contents of posts.designaton FROM user JOIN role ON user. SELECT user.id=post.department.department_id=department.role_id=role.id WHERE skill.post. 25) Write a query to display the names of the users who have posted posts and the contents of posts.profile_id=profile.degree_id=degree.id=post.content FROM user INNER JOIN post ON user.id JOIN experience ON profile.date.id WHERE role.name FROM user .content FROM user INNER JOIN query ON user.id JOIN profile_skills ON profile.name.id=profile_skills.name 29) Write a query to display the names of the users who have organized events and the name of the events.post.content FROM user INNER JOIN post ON user. AND experience. SELECT user. SELECT user. SELECT user.user_id SELECT user. sorted by name of the user.name 27) Write a query to display the names of the users who have posted posts in the year 2013 and the contents of posts.id JOIN profile ON user.post. 24) Write a query to display the names of the users who have answered queries and the content of the queries. sorted by name and then by date. sorted by name and then by post date.query.content FROM user INNER JOIN post ON user.date(date).name.content.profile_id WHERE role.query.name.id JOIN degree ON profile.post.role_id=role.name='Technology' ORDER BY user. sorted by name.gender='male' ORDER BY user. sorted by name and then by post date and then by content.name.id=experience.name.user_id ORDER BY name.id JOIN department ON degree.user_id WHERE year(post.name='Alumni' AND profile. sorted by name.id WHERE post_type. sorted by name of the user and then by event date.post.role_id=role.profile_id JOIN skill ON profile_skills.profile_id=profile. SELECT user. sorted by department name.name.name FROM role as r. profile_skills as ps.name = 'Alumni' AND u. SELECT role. Write a query to display the role name and the count of users in each role(Give an alias as role_count).role_id = r.id) as role_count FROM role as r LEFT OUTER JOIN user as u ON u.role r 5.event. SELECT u. Write a query to display the department name and the number of degrees offered by each department (Give an alias as degree_count).role_id ORDER BY role.name='Alumni' ORDER BY user.name.name. sorted by name.name ORDER BY COUNT(e.profile_id GROUP BY u.id AND r.role_id is not null GROUP BY user.name.event.name.role_id = r.name = 'Alumni' AND u.profile_id = p.date. Display all roles.role_id=role.name HAVING COUNT(*)>3 ORDER BY u.id AND r.id AND r.department_id = dm.name = 'Alumni' AND u.id AND p.id AND p.name = 'Alumni' GROUP BY u.skill_id = s. profile_skills as ps.profile_id) company_count FROM user u. SELECT u. 8.profile_id AND ps.id GROUP BY u.skill_id = s.name.id AND p. COUNT(*) as degree_count FROM degree as d.name. skill as s WHERE u. COUNT(d.date. SELECT user. sorted by name.name.name.id = e. 1.name FROM user INNER JOIN event ON user.id = e.COUNT(*) as role_count FROM user INNER JOIN role ON user.role_id = r.organiser_id ORDER BY user. skill as s WHERE u. experience as e WHERE u.role_id = r. 4. Display only the roles in which there is atleast 1 user. Display all departments.organiser_id JOIN role ON user. profile as p.profile_id = p. SELECT u.INNER JOIN event ON user. Write a query to display the role name and the count of users in each role(Give an alias as role_count).name ORDER BY u. department as dm WHERE d.id GROUP BY r. sorted by name and then by event date.id AND r. sorted by department name.id WHERE role.id GROUP BY dm. SELECT dm.name ORDER BY r.id = ps.role r WHERE u.id = ps.id AND p. experience as e WHERE u.id=event.role_id=role. 7. sorted by user name.profile_id AND ps.id) skill_count FROM user u. (SELECT COUNT(*) FROM role as r.name. SELECT r. Display only the departments which offer atleast 1 degree. role as r.profile_id) DESC LIMIT 1.name.'Alumni') who have organized events and the name of the events.role_id = r.name FROM user as u. 6.profile_id = p.id AND r.profile_id = p. 30) Write a query to display the names of the alumni users(role . profile as p. user as u. profile as p.id) as degree_count . Write a query to display the name of the alumni user(s) (Role-'Alumni') who has/have more than 3 skillsets. Write a query to display the department name and the number of degrees offered by each department (Give an alias as degree_count).id=event.name HAVING COUNT(*) >=1 ORDER BY dm. WHERE u. 3.id WHERE user.event. sorted by name.name.role_id = r. profile as p.id AND r. (SELECT COUNT(*) FROM role as r.name ='Alumni' AND u. SELECT dm.name ORDER BY u. 2.name. Write a query to display the name of all alumni user(s) (Role-'Alumni') and the number of companies in which each user has worked in (Give an alias as company_count).name = 'Alumni' GROUP BY u. sorted by name. Write a query to display the name of the alumni user(s) (Role-'Alumni') who has/have worked in maximum number of companies.name.role_id = r.name. sorted by name. --------------------------------------------------------------------------------------------------------------------------<<<<<<<<< SESSION 8 >>>>>>>>>>> --------------------------------------------------------------------------------------------------------------------------- SELECT u. COUNT(u. Write a query to display the name of all the alumni user(s) (Role-'Alumni') and the number of skillsets they possess (Give an alias as skill_count). sorted by name of the user.name.name.id GROUP BY dm.id) AS ct FROM user AS u.id AND p.name. Write a query to display the names of the user and the number of posts each user has posted (Give an alias as post_count). SELECT dm.name.id) >= 1 ORDER BY pt. Write a query to display the name(s) of the alumni user (Role-'Alumni') from 2008 batch who has/have posted the maximum number of posts. Write a query to display the department name and the number of alumni users registered in the system from each department (Give an alias as alumni_count). COUNT(u.name.department_id = dm.role as r WHERE u. SELECT u.name HAVING COUNT(p.department_id = dm.name='Alumni' AND p.id) = 3 ORDER BY dm.post as p.id AND d.id) as post_count FROM user as u LEFT OUTER JOIN post as p ON u.FROM department as dm LEFT OUTER JOIN degree as d ON d.id AND r.name HAVING COUNT(p. COUNT(p. sorted by department name. post_type as pt WHERE pt.id) = (SELECT MAX(ct) FROM (SELECT COUNT(p.batch='2008' GROUP BY u.profile_id = p.name FROM department as dm. 13.id = p. role as r WHERE u. Display only the names of users who have posted atleast one post. role as r WHERE u. 10.name ORDER BY dm.id AND u.user_id GROUP BY u.name HAVING COUNT(p.id) as post_count FROM post as p. COUNT(p.name. degree as d. SELECT u. user as u. profile as p.department_id = dm.id=p.id AND r. SELECT u.id) >= 1 ORDER BY dm.id) as post_count FROM user as u.name .id=p.profile as pf.name ORDER BY u. SELECT u.name.id AND d.id) >= 1 ORDER BY u. 15. Write a query to display the name(s) of the user who has/have posted the maximum number of posts. Display only departments in which atleast 3 alumni users have registered.id)>=3 ORDER BY u.name ) AS c ) ORDER BY u.id GROUP BY dm.profile_id = p.id HAVING COUNT(p. degree as d.name HAVING COUNT(u.name. user as u.id = p. Write a query to display the name of the department(s) offering the maximum number of degrees. degree as d WHERE d.id = p.profile_id=pf. . 9.name.name HAVING COUNT(d.role_id = r. sorted by name of the user.id AND p.department_id = dm.post AS p WHERE u.name FROM user AS u JOIN post AS p ON u. SELECT dm. COUNT(u. Write a query to display the names of the user and the number of posts each user has posted (Give an alias as post_count). 14.id) as alumni_count FROM department as dm.role_id=r. SELECT dm.name FROM user as u. post as p WHERE u.name.id AND r. profile as p. sorted by name. SELECT pt.user_id GROUP BY u. Display the names of all users. COUNT(p.name = 'Alumni' AND u.id GROUP BY dm. Write a query to display the department name and the number of alumni users registered in the system from each department (Give an alias as alumni_count).id) as alumni_count FROM department as dm. 12. Include only post_types under which there is atleast 1 post.user_id=u.name. 16.user_id GROUP BY u.id GROUP BY dm. sorted by department name.user_id WHERE u. Write a query to display the post_type and the number of posts posted under each type (Give an alias as post_count).degree_id = d.degree_id = d.name = 'Alumni' AND u.id) >= 3 ORDER BY dm.id AND pf.type_id GROUP BY pt. Display only departments from which atleast 1 alumni user has registered. sorted by department name.user_id GROUP BY u.role_id = r.name HAVING COUNT(u. 11. sorted by post_type. sorted by name.name.id = p.name. role as r WHERE u.name FROM user as u. Write a query to display the name(s) of the user and the batch of the user who has/have raised/answered most number of queries. department as dm. GROUP BY p.name = 'Alumni' AND u.department_id = dm. query as q WHERE u. Write a query to display the name(s) of the alumni user (Role-'Alumni') from 2008 batch CSE department who has/have posted the maximum number of posts. Display only the names of users who have organized atleast one event.17.organiser_id GROUP BY u. profile_id.user_id) = 6 ORDER BY u. COUNT(e.name. 22. Write a query to display the name(s) of the user who has/have answered most number of queries. post as ps.id = ps.id = q. Write a query to display the batch and the number of users who have been or are a part of 'TCS' (Give an alias as TCS_count). 21.batch = '2008' AND p.profile_id) as TCS_count FROM profile as p.id = e.name FROM user as u. sorted by name.id FROM user) as u JOIN profile ON u.profile_id = p.company_name = 'TCS' SELECT u. Write a query to display the names of the user and the number of events each user has organized (Give an alias as event_count).organiser_id GROUP BY u. sorted by name.profile_id = p. SELECT u.id = q. 25. event as e WHERE u.name ORDER BY u. sorted by name of the user.id JOIN degree ON profile.id = e. Write a query to display the names of the user and the number of events each user has organized (Give an alias as event_count). profile as p WHERE u.id HAVING COUNT(ps. SELECT u.id GROUP BY u. sorted by name. 19. SELECT p.name. Display only batches in which TCS_count is atleast 1.batch.id = e.name HAVING COUNT(q. Use column alias name as USER_NAME and DEPT_NAME SELECT user_name.name.batch HAVING COUNT(e.degree_id = d. sorted by name.profile_id=profile. COUNT(e. p.batch.organiser_id) >= 1 ORDER BY u.degree_id=degree. degree as d.id AND r. 20.user_id GROUP BY u.user_id AND u.profile_id) >= 1 ORDER BY p.name HAVING COUNT(e. sorted by name.user_id)>= 3 ORDER BY u.user_id) = 6 ORDER BY u.name. dept_name FROM (SELECT name as user_name.organiser_id) as event_count FROM user as u LEFT OUTER JOIN event as e ON u. query as q WHERE u.user_id GROUP BY u.id FROM department)as d ON d.name = 'CSE' AND u.content)=6 ORDER BY user_name. 24.department_id JOIN query ON query. SELECT u.user_id=u. sorted by name.name FROM user as u.id AND d. profile as p. Write a query to display the name(s) of the user and the department of the user who has/have raised/answered most number of queries. Write a query to display the name(s) of the user who has/have organised the maximum number of events.name. SELECT u. COUNT(e.id GROUP BY user_name having COUNT(query. Write a query to display the name(s) of the user who has/have raised/answered most number of queries. SELECT u.id = q.role_id = r. SELECT u.name. sorted by batch.user_id GROUP BY u.name.id JOIN (SELECT name as dept_name.organiser_id) as event_count FROM user as u.name.id = e.organiser_id GROUP BY u.id=degree.organiser_id) = 5 ORDER BY u.user_id) = 2 ORDER BY u. sorted by name of the user. 18.profile_id AND e. query as q.name HAVING COUNT(q.name.name FROM user as u. Display the names of all users.batch FROM user as u.id AND p. event as e WHERE u.id AND dm.name HAVING COUNT(e.name HAVING COUNT(q. 23. experience as e WHERE p.name. . role.--------------------------------------------------------------------------------------------------------------------------<<<<<<<<< SESSION 9 >>>>>>>>>>> --------------------------------------------------------------------------------------------------------------------------1) Write a query to display the names of all administrators (role Admin) sorted by name in Ascending order.name ASC. role WHERE role. 2) Write a query to display the names of all alumni (role Alumni) sorted by name in descending order.name='Ram' 8) Write a query to display the designaton of Ram.id AND user.profile_id=p. SELECT skill.profile_id=p.profile_id=p.name='Ram' SELECT query.name='BSC_CT'.name='ram' ORDER BY skill.name FROM user.name FROM user.id AND user.name DESC.project as pj WHERE u. SELECT department.department_id = department.start. 9) Write a query to display the name of the skillsets of Ram.name FROM user.name FROM user.department_id = department.name='Ram' ORDER BY query.user_id=user.content . 5) Write a query to display the names of all female alumni (role Alumni). sorted in Ascending order. sorted by name in Ascending order.role_id AND role.id AND user.id=user.profile_id AND user.id AND u.id AND user.id AND user. sorted in Ascending order.name='alumni' AND profile.profile as p.university_name FROM user. SELECT user.name='alumni' ORDER BY user. sorted in order. department. sorted by date. SELECT department.id AND user.name='admin' ORDER BY user.profile_skills.profile WHERE role.profile_id=profile.name='CSE' ORDER BY degree. sorted by start date. SELECT higher_degree. department WHERE degree.id=user. start date and end date in order).profile WHERE user.e.profile as p.profile_id=profile.id=user.name FROM user as u.id AND e.name ASC.content FROM user.name FROM user.skill WHERE user.name='Anithaa' ORDER BY e. 6) Write a query to display the department of user Ram in the college.name ASC.gender='female' ORDER BY user.role_id AND role.name 12) Write a query to display the contents of queries raised or answered by Ram.experience as e WHERE u. sorted in order.role WHERE role.id AND role.id=higher_degree.query WHERE query.profile_id = profile.end FROM user as u.id AND profile_skills.name FROM degree.degree_id = degree.name ASC 10) Write a query to display the work experience details of Anithaa (company name.profile_id=profile. SELECT profile. degree. profile WHERE profile.id AND degree. SELECT post.name='Ram' ORDER BY pj.designaton FROM user.id AND degree. sorted by date.profile. SELECT user.profile_id=p.id AND department.name='Ram'.start 11) Write a query to display the names of projects in which Ram has been a part of. SELECT pj.id AND profile_skills.profile_id=profile.company_name.id AND u.higher_degree.role_id AND user. 7) Write a query to display the university name(s) in which Ram has done his higher studies.e.department_id = department. department WHERE degree. SELECT user. SELECT degree. SELECT e.skill_id=skill.name FROM degree.profile_id=profile.id AND pj.date 13) Write a query to display the contents of posts posted by Ram.profile WHERE profile. 3) Write a query to display the names of all degrees offered by 'CSE' department. 4) Write a query to display the name of the department offering the degree 'BSC_CT'. skill_id=skill.name ASC.name='Alumni' ORDER BY u. SELECT user.content FROM user. SELECT user.profile.role_id=role. SELECT u. SELECT user.id AND profile.role.profile_id=profile.name ASC.gender='male' ORDER BY u. 24) Write a query to display the name and role of all users. SELECT u.name='Technology' ORDER BY post.id AND user.batch=2008 AND role.experience WHERE user.profile_id=profile.profile_id=profile.profile_id=profile.id AND degree.id AND user.profile.content FROM user. SELECT u.name='Alumni' AND profile.name FROM user as u.current='1' ORDER BY user.id AND department.name='alumni' AND experience.batch=2008 AND role.profile_id=profile.post WHERE post.user.degree_id=degree.id AND role.name='Ram' AND YEAR(post.profile WHERE u.name.name FROM user as u.role.name='Alumni' AND profile.role .name='Ram' AND post_type.post WHERE post.profile_id=profile.emailid FROM user.id AND user.role_id=role. sorted by name.name='Alumni' ORDER BY u.user_id=user.degree WHERE u.department_id=department. SELECT post.name FROM user.name='Ram' ORDER BY post.role_id=role. 22) Write a query to display the names of all alumni users who have been or are a part of TCS.profile_id=profile.profile_skills.date)='2012' ORDER BY post.name ='BSC_CT'AND profile. 17) Write a query to display the name of all male Alumni from 2008 batch. sorted by name.profile_id=profile.role.profile_id=profile. 21) Write a query to display the names of users who have good 'Web Design' skills.batch=2008 AND role.id AND skill.name.company_name='TCS' AND experience.profile WHERE user.id AND role.name ASC. 18) Write a query to display the name of all Alumni from BSC_CT 2008 batch.name.id AND profile.id AND u. skill WHERE user.name FROM user.u.name.id AND experience.degree_id=degree. sorted by date.batch=2008 ORDER BY user.role_id=role. sorted by name of the user.name='alumni' AND experience.role_id=role.id AND user. SELECT post.id AND profile. SELECT user. sorted by date.id AND degree.role. sorted in Ascending order based on name.profile.id AND u.user_id=user.name.id AND profile_skills.profile.emailid FROM user.post. 20) Write a query to display the name and email details of all users from 2008 batch sorted by name.id AND u.phonenumber FROM user as u.post_type WHERE post.profile.profile_id=profile.FROM user.id AND profile_skills.role.profile_id=profile.name='Web Design' ORDER BY user.name FROM user.date 14) Write a query to display the contents of posts related to Technology posted by Ram.profile WHERE u.id AND user.id AND profile.date 15) Write a query to display the contents of posts posted by Ram in the year 2012.role.gender='male' ORDER BY u. 23) Write a query to display the names and email ids of all alumni users who are currently working in TCS.id AND experience.name ASC.batch=2008 AND role. 19) Write a query to display the name of all Alumni of 2008 batch from CSE department.degree.company_name='TCS' ORDER BY user. sorted by name.experience WHERE user.name ='CSE' AND profile.date 16) Write a query to display the name and phone numbers of all Alumni users from 2008 batch. SELECT u.name.department WHERE u. sorted by name.id AND post.type_id=post_type.name.user.name.id AND u. SELECT user. sorted by name.name FROM user as u.user_id=user.role.role_id=role.id AND profile. sorted in order. 3) Write a query to display the names of users from 2008 batch CSE department who have done their higher studies in 'Texas University'.name ASC. SELECT name FROM user WHERE profile_id IN (SELECT profile_id FROM higher_degree WHERE university_name='Texas University') AND profile_id IN (SELECT id FROM profile WHERE batch=2008 AND degree_id IN (SELECT id FROM degree WHERE department_id in (SELECT id ) ORDER BY name.name ASC.role_id=role.id IS NOT NULL ORDER BY user.name. SELECT name FROM user WHERE profile_id IN (SELECT profile_id FROM higher_degree WHERE university_name='Texas University') AND profile_id IN (SELECT id FROM profile WHERE batch=2008) ORDER BY name.role_id=role.role.name FROM user. 5) Write a query to display the names of users from 'MECH' department who are currently working in 'TCS'. sorted in order. SELECT user.role. SELECT name FROM user . SELECT name FROM user WHERE profile_id in (SELECT profile_id FROM profile_skills WHERE profile_id IN (SELECT id FROM profile WHERE degree_id in (SELECT id FROM degree WHERE department_id IN (SELECT id FROM department WHERE name='MECH') ) ) AND skill_id in (SELECT id FROM skill WHERE name='Programming') ) ORDER BY name.id AND profile. 2) Write a query to display the names of users from 2008 batch who have done their higher studies in 'Texas University'. 6) Write a query to display the names of users who have been part of projects with more than 10 members. sorted in order.profile WHERE user.id AND user. sorted in order. SELECT name FROM user WHERE profile_id IN (SELECT profile_id FROM higher_degree WHERE university_name='Texas University') ORDER BY name.WHERE user. sorted in order. SELECT name FROM user WHERE profile_id in (SELECT profile_id FROM experience WHERE profile_id IN (SELECT id FROM profile WHERE degree_id IN (SELECT id FROM degree WHERE department_id IN (SELECT id FROM department WHERE name='MECH') )) AND company_name='TCS' AND current=1) ORDER BY name. 4) Write a query to display the names of users from 'MECH' department who have 'Programming' skills. --------------------------------------------------------------------------------------------------------------------------<<<<<<<<< SESSION 10 >>>>>>>>>>> --------------------------------------------------------------------------------------------------------------------------1) Write a query to display the names of users who have done their higher studies in 'Texas University'. sorted in order. FROM department WHERE name='CSE') ) 25) Write a query to display the name and role details of all users who have filled in the profile details. sorted in order. sorted by name in Ascending order.profile_id=profile.id ORDER BY user. 15) Write a query to display the name. SELECT name FROM user WHERE id in (SELECT user_id FROM query WHERE parent_id is null) ORDER BY name. phone number and email id of organizer of 'ICSIP2008'. 19) Write a query to display the names of users who have been working in TCS in the year 2012. 9) Write a query to display the names of users who have answered queries. sorted in order. sorted in order.emailid FROM user WHERE id in (SELECT organiser_id FROM event WHERE name='ICSIP 2008'). 10) Write a query to display the names of users from 2008 batch who have raised queries. SELECT name. 12) Write a query to display the names of users who have organised events. SELECT name FROM user WHERE id in (SELECT organiser_id FROM event) AND role_id in (SELECT id FROM role WHERE name='Alumni') ORDER BY name. 14) Write a query to display the names of users who have organized events in the year 2013. sorted in order. sorted in order. SELECT name FROM user WHERE id in (SELECT user_id FROM query WHERE parent_id is NOT NULL) ORDER BY name. 7) Write a query to display the names of users from 2008 batch who have raised or answered queries. SELECT name FROM user WHERE profile_id IN (SELECT profile_id FROM higher_degree WHERE university_name IS NOT NULL) ORDER BY name 13) Write a query to display the names of 'Alumni' users who have organised events. . 16) Write a query to display the names of all users who have posted 'Technology' related posts in the year 2013. SELECT name FROM user WHERE profile_id in (SELECT profile_id FROM experience WHERE profile_id in (SELECT id FROM profile WHERE designaton='Project Manager') AND company_name='TCS' AND current=1) ORDER BY name. 8) Write a query to display the names of users who have raised queries. sorted in order. SELECT name FROM user WHERE profile_id IN (SELECT id FROM profile WHERE batch=2008) AND id IN (SELECT user_id FROM query ) ORDER BY name. sorted in order. sorted by name in order. [Hint : Details of higher studies done in other colleges / universities is specified in the higher_degree table]. 11) Write a query to display the names of users from 2008 who have answered queries. SELECT name FROM user WHERE id in (SELECT user_id FROM query WHERE parent_id is not null) AND profile_id in (SELECT id FROM profile WHERE batch=2008) ORDER BY name. SELECT name FROM user WHERE id in (SELECT user_id FROM query WHERE parent_id is null ) AND profile_id in (SELECT id FROM profile WHERE batch=2008) ORDER BY name. sorted in order.phONenumber.WHERE profile_id IN (SELECT profile_id FROM project WHERE number_of_members>10) ORDER BY name. SELECT name FROM user WHERE id in (SELECT organiser_id FROM event) ORDER BY name. sorted in order. SELECT name FROM user WHERE id in (SELECT user_id FROM post WHERE type_id in (SELECT id FROM post_type WHERE name='Technology') AND year(date)='2013') ORDER BY name. sorted in order. sorted in order. sorted in order. 18) Write a query to display the names of users who have done their higher studies in other colleges or universities. SELECT name FROM user WHERE id in (SELECT organiser_id FROM event WHERE year(date)='2013') ORDER BY name. 17) Write a query to display the names of users who are currently working in TCS as 'Project Manager's. 'Alumni') who have not raised or answered queries. --------------------------------------------------------------------------------------------------------------------------<<<<<<<<< SESSION 11 >>>>>>>>>>> --------------------------------------------------------------------------------------------------------------------------1) Create a view named view_alumni_details that contains the name.id left outer JOIN profile ON profile. SELECT COUNT(id) AS coordinator_count FROM user WHERE role_id IN (SELECT id FROM role WHERE name='ALUMNI COORDINATOR').'Alumni') . Give an alias as 'event_count'. (Include users who have never been employed also).profile p.company_name as company_name FROM role JOIN user ON user.name.experience. 20) Write a query to display the number of events organised by alumni users. 24) Write a query to display the alumni users (Role .profile_id .id=p. degree. 3) Create a view named view_experience_details that contains the name and all company names in which they have worked of all alumni users(role .profile_id=p.department_id=dt. CREATE OR REPLACE VIEW view_alumni_details as SELECT u.name as degree_name.phONenumber. SELECT name FROM user WHERE profile_id IN (SELECT profile_id FROM project WHERE number_of_members=(SELECT MIN(number_of_members) FROM project)) ORDER BY name.role_id AND u. SELECT COUNT(id) AS degree_count FROM degree WHERE department_id IN (SELECT id FROM department WHERE name='CSE').name as degree_name .name='Alumni' ORDER BY u.sorted by name of the user. Give an alias to the user name as user_name and degree as degree_name.SELECT name FROM user WHERE profile_id in (SELECT profile_id FROM experience WHERE company_name='TCS' AND ((year(end)>='2012' AND year(start)<='2012') or end is null)) ORDER BY name.id AND d. sorted by name and then by company name. SELECT COUNT(id) AS cse_alumni_count FROM user WHERE role_id in (SELECT id FROM role WHERE name='Alumni') AND profile_id in (SELECT id FROM profile WHERE degree_id in (SELECT id FROM degree WHERE department_id in (SELECT id FROM department WHERE name='CSE') )).role r WHERE r. SELECT COUNT(id) AS event_count FROM event WHERE organiser_id in (SELECT id FROM user WHERE role_id in (SELECT id FROM role WHERE name='Alumni') ). Give an alias to the degree name as degree_name and department name as dept_name. 22) Write a query to display the number of 'Alumni Coordinator's.dt.role_id=role.u. Give an alias as cse_alumni_count. sorted by name of the user. 2) Create a view named view_degree_details that contains the name of the degrees and the departments offering the degrees sorted by degree name.name as dept_name FROM degree d.department dt WHERE d.id=u.name as user_name. 23) Write a query to display the number of alumni from CSE department who have registered in the system. Give an alias as 'coordinator_count'. CREATE OR REPLACE VIEW view_experience_details as SELECT user. Give an alias to the user name as user_name and company name as company_name.batch. 21) Write a query to display the number of degrees offered by CSE department. SELECT name FROM user WHERE id NOT IN (SELECT user_id FROM query ) AND role_id in (SELECT id FROM role WHERE name='Alumni') ORDER BY name.id=user.u.name. Give an alias as 'degree_count'.id ORDER BY d. batch.degree_id AND r.name as user_name.degree d.emailid FROM user u. phonenumber and emailid of all alumni users(role -'Alumni') sorted by name.p.d. 25) Write a query to display the names of the users who have worked in the project(s) with minimum members. CREATE OR REPLACE VIEW view_degree_details as SELECT d. organiser_id GROUP BY u.organiser_id ORDER BY event.emailid.name as event_name FROM user JOIN event ON user.name. emailid and designaton of all alumni users(role .name.id=profile. Give an alias to the user name as user_name and event name as event_name.profile_id=profile. email id and phone number of all alumni(role . COUNT(e.id JOIN profile ON profile.degree.profile_id) AS TCS_count FROM profile as p. sorted by name of the user and then by event date. 10) Create a view named view_skillset_count_details that contains the name of all the alumni user(s) (Role-'Alumni') and the number of skillsets they possess (Give an alias as skill_count).name HAVING COUNT(e.gender='Female' AND role.id=user. --------------------------------------------------------------------------------------------------------------------------<<<<<<<<< SESSION END >>>>>>>>>>> --------------------------------------------------------------------------------------------------------------------------- .name. 5) Create a view named view_female_alumni_details that contains the name.company_name='TCS' AND experience.batch.name='Alumni' ORDER BY user.role r WHERE r. 9) Create a view named view_event_count_details that contains the names of the user and the number of events each user has organized (Give an alias as event_count).profile_id JOIN experience ON experience.id=event.batch.name as degree_name FROM role JOIN user ON role. experience as e WHERE p. CREATE OR REPLACE VIEW view_BSC_CT_details as SELECT user. COUNT(e.name='BSC_CT' AND role.id=u.name='Alumni' AND experience. 7) Create a view named view_event_details that contains the names of the users who have organized events and the name of the events.name as user_name.'Alumni') who are currently working in TCS.user.name ORDER BY u.degree_id WHERE degree.profile_id=profile. CREATE OR REPLACE VIEW view_female_alumni_details as SELECT user.name.date.organiser_id) as event_count FROM user as u.name.profile_id AND us.user.(SELECT COUNT(*) FROM user us. CREATE OR REPLACE VIEW view_event_count_details as SELECT u. sorted by name.id=user.role_id JOIN profile ON profile. Include only batches in which TCS_count is atleast 1.profile_id AND e.name) AS skill_count FROM user u. 4) create a view named view_BSC_CT_details that contains the name.name='Alumni' ORDER BY user.profile.name='Alumni' ORDER BY user. Include only the names of users who have organized atleast one event.batch.name.emailid.name. CREATE OR REPLACE VIEW view_TCS_alumni_details as SELECT user.profile_id) >= 1 ORDER BY p.id=user.id=profile.id WHERE role.profile_id=ps. event as e WHERE u.phONenumber FROM role JOIN user ON user.event. sorted by name. sorted by name. sorted by name of the user.name.role_id=role.degree_id WHERE profile.company_name = 'TCS' GROUP BY p.id=user.designaton FROM user JOIN role ON role.batch HAVING COUNT(e. 6) Create a view named view_TCS_alumni_details that contains the name.experience. Give an alias to the user name as user_name and degree name as degree_name.user.role_id GROUP BY u. CREATE OR REPLACE VIEW view_skillSET_count_details AS SELECT u. 8) Create a view named view_TCS_batchwise_count_details that contains the batch and the number of users who have been or are a part of 'TCS' (Give an alias as TCS_count). sorted by batch. CREATE OR REPLACE VIEW view_TCS_batchwise_count_details as SELECT p.name. CREATE OR REPLACE VIEW view_event_details as SELECT user.name='Alumni' AND r.organiser_id) >= 1 ORDER BY u.'Alumni') users from 'BSC_CT'. sorted by name of the user.JOIN experience ON experience.role_id JOIN profile ON profile.name=u.profile. batch and degree of all female alumni users(role .current=1 ORDER BY user.id = e.profile_skills ps WHERE us.profile_id JOIN degree ON degree.id=user.id = e.company_name.profile_id JOIN degree ON degree.'Alumni').name as user_name.name .id AND role.
Copyright © 2024 DOKUMEN.SITE Inc.