Computer Science
Consider the following two SQL commands with reference to a table, named MOVIES, having a column named Director:
(a) Select Distinct Director from MOVIES;
(b) Select Director from MOVIES;
- In which case will these two commands produce the same result?
- In which case will these two commands produce different results?
SQL Queries
2 Likes
Answer
The two SQL commands will produce the same result when there are no duplicate values in the Director column of the MOVIES table. If every Director value in the table is unique, both commands will return the same set of distinct Director values.
The two SQL commands will produce different results when there are duplicate values in the Director column of the MOVIES table. The first command with DISTINCT will only return unique Director values, omitting duplicates, whereas the second command without DISTINCT will return all Director values, including duplicates.
Answered By
1 Like
Related Questions
Write the output of the code given below:
d1 = {"A" : "Avocado", "B" : "Banana"} d2 = {'B' : 'Bag', 'C' : 'Couch'} d2.update(d1) print(len(d2))What will the following snippet print?
L5 = [1500, 1800, 1600, 1200, 1900] begin = 1 sum = 0 for c in range(begin, 4): sum = sum + L5[c] print(c, ':', sum) sum = sum + L5[0] * 10 print("sum is", sum)Write a function WordsList(S), where S is a string. The function returns a list, named Words, that stores all the words from the string which contain 'r'.
For example, if S is "Dew drops were shining in the morning", then the list Words should be: ['drops', 'were', 'morning']
In a database BANK, there are two tables with a sample data given below:
Table: EMPLOYEE
ENo EName Salary Zone Age Grade Dept 1 Mona 70000 East 40 A 10 2 Mukhtar 71000 West 45 B 20 3 Nalini 60000 East 26 A 10 4 Sanaj 65000 South 36 A 20 5 Surya 58000 North 30 B 30 Table: DEPARTMENT
Dept DName HOD 10 Computers 1 20 Economics 2 30 English 5 (a) To display ENo, EName, Salary and corresponding DName of all the employees whose age is between 25 and 35 (both values inclusive).
(b) To display DName and corresponding EName from the tables DEPARTMENT and EMPLOYEE (Hint: HOD of DEPARTMENT table should be matched with ENo of EMPLOYEE table for getting the desired result).
(c) To display EName, Salary, Zone and Income Tax (Note: Income tax to be calculated as 30% of salary) of all the employees with appropriate column headings.