find the names of all students who have taken at least one comp. sci. course

by Keanu Nitzsche 6 min read

How do I count students in SQL?

SQL SELECT COUNT(DISTINCT column_name) SELECT COUNT(DISTINCT column_name) counts the total number of distinct values of column in the table. Refer this guide – SQL DISTINCT to learn more about SQL SELECT DISTINCT statement. Query: Lets take the same table STUDENT that we have taken in the above example.

What is the query to increase the salary of each instructor in the Comp Sci department by 10%?

Increase the salary of each instructor in the Comp. Sci. department by 10%. update instructorset salary = salary * 1.10where dept name = 'Comp.

How can I list all customers who are located in the same city in my SQL?

SELECT id, name, city FROM persons JOIN (SELECT city FROM persons GROUP BY city HAVING count(*) > 1) AS cities USING (city); This might be the most performant solution.

Which query will retrieve the rows from a table menu?

SELECT SQL Query SELECT query is used to retrieve data from a table. It is the most used SQL query. We can retrieve complete table data, or partial by specifying conditions using the WHERE clause.

How do you increase a salary by 10 percent in SQL?

The following will increase the salaries of all the employees to 10% in the Employee table using a single UPDATE statement. UPDATE Employee SET Salary = Salary + (Salary * 10/100); Now, the Select * from Employee query will display the following result.

How do I create a student database in SQL?

SolutionCreating student table. ... Describe the structure of the table. ... Insert few records into student table. ... Add column to the student table (that is phone_no). ... Modify the column name of phone_no to student_no. ... Rename the table name to student_info. ... Delete any records from the table.

How use LIKE operator in SQL for multiple values?

The SQL LIKE clause is used to compare a value to similar values using wildcard operators. There are two wildcards used in conjunction with the LIKE operator. The percent sign represents zero, one or multiple characters. The underscore represents a single number or character.

How do you SELECT all the records from a table named persons?

With SQL, how do you select all the columns from a table named "Persons"?Click the icon SQL Worksheet. The SQL Worksheet pane appears.In the field under "Enter SQL Statement:", enter this query: SELECT * FROM SLIGHTBOOK;Click the Execute Statement. The query runs.Click the tab Results.

How can I get first name and last name both in a single column string concatenation in SQL?

1. select FirstName +' '+ MiddleName +' ' + Lastname as Name from TableName.

How can we retrieve data using primary key in SQL?

Here are a few lines of sql query using which we can get the primary column name.select C.COLUMN_NAME FROM.INFORMATION_SCHEMA.TABLE_CONSTRAINTS T.JOIN INFORMATION_SCHEMA.CONSTRAINT_COLUMN_USAGE C.ON C.CONSTRAINT_NAME=T.CONSTRAINT_NAME.WHERE.C.TABLE_NAME='Employee'and T.CONSTRAINT_TYPE='PRIMARY KEY'

How can I retrieve data from SQL?

The syntax is: SELECT column1, column2 FROM table1, table2 WHERE column2='value'; In the above SQL statement: The SELECT clause specifies one or more columns to be retrieved; to specify multiple columns, use a comma and a space between column names.

Which is used to retrieve data from tables Mcq?

Select SQL is used to retrieve or fetch data from a table in the database.

How do I count customers in SQL?

The COUNT(*) function returns the number of orders for each customerid . The HAVING clause gets only groups that have more than 20 orders.

What is self join example?

A self join is a join in which a table is joined with itself (which is also called Unary relationships), especially when the table has a FOREIGN KEY which references its own PRIMARY KEY. To join a table itself means that each row of the table is combined with itself and with every other row of the table.

How do you represent not equal to in SQL?

The SQL Not Equal comparison operator (!=) is used to compare two expressions. For example, 15 !=

How do I count the number of orders in SQL?

The first step is to use the GROUP BY clause to create the groups (in our example, we group by the country column). Then, in the ORDER BY clause, you use the aggregate function COUNT, which counts the number of values in the column of your choice; in our example, we count distinct IDs with COUNT(id) .

Why do departments need to have at least one instructor?

A department needs to have at least one instructor in order for building and budget information to be included in the table. Nulls canbe used when there is no instructor, but null values are rather difficult to handle.

Why is there a foreign key when you delete a course?

If we try to delete the course directly, there will be a foreign key vio- lation because section has a foriegn key reference to course ; similarly, we have to delete corresponding tuples from takes before deleting sections, since there is a foreign key reference from takes to section . As a result of the foreign key violation, the transaction that performs the delete would be rolled back.

What happens if there are more than one student named Chavez?

Note that if there is more than one student named Chavez, all such students would have their enrollments deleted. If we had used= instead of in , an error would have resulted if there were more than one student named Chavez.

What is the difference between two tier and three tier architectures?

Which is better suited for Web applications? Why? Answer: In a two-tier application architecture, the application runs on the client machine, and directly communicates with the database system running on server. In contrast, in a three-tier architecture, application code running on the client’s machine communicates with an application server at the server, and never directly communicates with the database. The three-tier archicture is better suited for Web applications. 1.15 Describe at least 3 tables that might be used to store information in a social- networking system such as Facebook. Answer: Some possible tables are:

What happens if all instructors are deleted?

If all instructors in a department are deleted, the buildingand budget information are also lost. Ideally, we would like to have thedepartment information in the database irrespective of whether the department has an associated instructor or not, without resorting to null values.

image