1

My SQL -----database---- What restrictions apply to the use of the aggregate functions within the SELECT...

Question

My SQL -----database---- What restrictions apply to the use of the aggregate functions within the SELECT...

My SQL -----database----

What restrictions apply to the use of the aggregate functions within the SELECT statement? How do nulls affect the aggregate

What restrictions apply to the use of the aggregate functions within the SELECT statement? How do nulls affect the aggregate functions? Give a complete example, Explain how the GROUP BY clause works. What is the different between the WHERE and HAVING clauses? Give an example

Answers

Following are the restrictions that apply to the aggregate functions within the select statement :

  1. Some of the aggregate functions(Sum and avg) can only be applied to numeric data.
  2. An aggregate function with a non-aggregate can't be used simultaneously in a single sql query.
  3. It usually ignores null values.

Null values are all ignored by the aggregate functions except in the case of count function.

Example: consider a table instructors as follows

Name Department salary Age
Arun Prakash cs 40000 45
sam allans ee 30000 52
charlie white cs 20000 57
joseph ee null 35
piyush cs null 30
ram mohan it 20000 40

joseph and piyush are newly joined so there salary are null.

if we want the salary of all the instructors paid by the college we can write the query :

select sum(salary) from instructor;

output is:

sum(salary)
110000

Group by clause is used when we have to apply aggregate functions for a group of set of tuples, it first groups the table according to some attribute and then apply the aggregate function on each group.

The where clause is used when we have to apply condition to tuples while the having clause is used when we have to apply condition to a group.

Example : if we want to find the average salary of all the departments where average salary is greater then 25000 we write the following query:

select department, avg(salary) from instructor group by department having avg(salary) > 25000;

output:

department avg(salary)
cs 30000
ee 30000


Similar Solved Questions

1 answers
Pratish weighs 588 N and is weightless in a space station. If she pushes off the wall with a vertical acceleration of 3.00 m/s squared, what is the force exerted by the wall during her push off?
Pratish weighs 588 N and is weightless in a space station. If she pushes off the wall with a vertical acceleration of 3.00 m/s squared, what is the force exerted by the wall during her push off?...
1 answers
Accounting and the Bus S1-5 Applying accounting assumptions and principles Learnir Michael McNamee is the proprietor...
Accounting and the Bus S1-5 Applying accounting assumptions and principles Learnir Michael McNamee is the proprietor of a property management company, Apartment Exchange, near the campus of Pensacola State College. The business has cash of $8,000 and furniture that cost $9.000 and has a market value...
1 answers
Sketch the graph of r = 2 by finding the set of points whose polar coordinates...
Sketch the graph of r = 2 by finding the set of points whose polar coordinates have r = 2 (along with any 8). Check by finding a Cartesian formula for this shape (hint; in the notes we have a formula for p in terms of ar and y) Sketch the graph of 0 = by finding the set of points whose polar coordin...
1 answers
7.2. Which of the following functions represent a probability density function for a continuous random variable?...
7.2. Which of the following functions represent a probability density function for a continuous random variable? Hint: Check if both rules of a proper probability density function hold. (a) f(z) = 0.25 where 0-1-8. b) f(r) =1/2 where 0 <1<2...
1 answers
In your own words, define and discuss the following terms: data, information and knowledge. Then, give...
In your own words, define and discuss the following terms: data, information and knowledge. Then, give a health related example of each - data, information, and knowledge (For example - data- 166, information 166 lbs, knowledge - 166 lbs is the average weight of an adult female)....
1 answers
Question 4 2 pts How many years had the 20th century been around when Medicare and...
Question 4 2 pts How many years had the 20th century been around when Medicare and Medicaid legislature was passed? (Level 1) O a. 110 years O b. 65 years O c. 35 years d. 9 years e. None of the above...
1 answers
How do I solve the rational inequality #(x^2-1)/(x+1)<2# using a TI-83?
How do I solve the rational inequality #(x^2-1)/(x+1)<2# using a TI-83?...
1 answers
Ace Products sells marked playing cards to blackjack dealers. It has not paid a dividend in...
Ace Products sells marked playing cards to blackjack dealers. It has not paid a dividend in many years, but is currently contemplating some kind of dividend. The capital accounts for the firm are as follows: Common stock (3,000,000 shares at $5 par) Capital in excess of par* Retained earnings Net wo...
1 answers
General Electric manufactures turbines and provides the following annual data. How many turbines were transferred to...
General Electric manufactures turbines and provides the following annual data. How many turbines were transferred to finished goods during the year? General Electric uses the weighted average method for process costing calculations Beginning Work in Process (30% complete, $1,300) Ending inventory of...
1 answers
Note 1: The currents in the picture may or may not be shown in the correct...
Note 1: The currents in the picture may or may not be shown in the correct direction. The actual direction depends on the values used in the problem. If you get a negative value, please enter it. This means that the current is actually traveling in the other direction. Note 2 : You may solve for the...
1 answers
Question 13 5 pts In the cycle shown here, the mass fractions at point 5 and...
Question 13 5 pts In the cycle shown here, the mass fractions at point 5 and 6 are x and y, respectively. Write the 1st law equation for the turbine. Expansion valve Boiler Turbine Process heater Condenser Pump II Pump I...
1 answers
According to a study of political prisoners, the mean duration of imprisonment for 39 prisoners with...
According to a study of political prisoners, the mean duration of imprisonment for 39 prisoners with chronic post-traumatic stress disorder (PTSD) was 31.2 months Assuming that σ=44 months, determine a 95% confidence interval for the mean duration of imprisonment, μ, of all political prison...
1 answers
Create a partition of our class. It must be made of at least 3 subsets, and...
Create a partition of our class. It must be made of at least 3 subsets, and fewer than total number of people in the class. (So you cannot have the partition be each separate person in their own subset.) List the subsets of your partition. Explain the equivalence relation that matches your partition...
1 answers
Can you define these terms in 3-4 sentences. Thank you 20. Hard power 21. Soft power...
Can you define these terms in 3-4 sentences. Thank you 20. Hard power 21. Soft power 22. Realism 23. Liberal institutionalism 24. Anarchy 25. Balance of Power 26. The EU 27. IGOs 28. Cosmopolitanism 29. Multilateralism 30. The UN 31. European Coal and Steel Community 32. EEC 33. Interdependence 34...
1 answers
Please explain even small steps and im having trouble with the moments so please explain that...
please explain even small steps and im having trouble with the moments so please explain that too thanks (6) The forces and couples shown are applied to two screws as a piece sheet metal is fastened to a block of wood. Reduce the forces and the couples to an equivalent wrench, and determine (a)...
1 answers
A Canvas » XĀ Question 15 Consider the following data. What is the SS total? Note....
a Canvas » XĀ Question 15 Consider the following data. What is the SS total? Note. Avoid selecting the final option if your answer is only different by.0001 or.0002 from the other available options. Variable B Group 1 Variable A Group Group 3 10 15 19 20 25 Group 1 14 Group 2 29 340.0333 ...
1 answers
3. A web-based store is stuck with a very large set of three kinds of unsold...
3. A web-based store is stuck with a very large set of three kinds of unsold Christmas snow globes: Globes with a Nutcracker figurine, globes with a Santa figurine, and globes with a Snowman (see pictures below from left to right). 3. A web-based store is stuck with a very large set of three kinds ...
1 answers
Asap Question 16 of 31 For the optical fiber shown in the figure, find the minimum...
asap Question 16 of 31 For the optical fiber shown in the figure, find the minimum angle of incidence (0) that will result in total internal reflection if the refractive index for the cladding (n) is 1.48 and the refractive index of the core is (A.) n = 1.57 and (B.) n = 1.80. Cone of acceptanc...

-- 0.011259--