You work for an organization that monitors seismic activity around volcanos. You have a table named GroundSensors. The table stores data collected from seismic sensors that measure earthquake activity

Posted by: Pdfprep Category: 70-761 Tags: , ,

SIMULATION

You work for an organization that monitors seismic activity around volcanos. You have a table named GroundSensors. The table stores data collected from seismic sensors that measure earthquake activity.

It includes the columns described in the following table:

The database also contains a scalar value function named NearestMountain that returns the name of the mountain that is nearest to the sensor.

You need to create a query that shows the average of the normalized readings from the sensors for each mountain.

The query must meet the following requirements:

– Include the average normalized readings and nearest mountain name.

– Exclude sensors for which no normalized reading exists.

– Exclude those sensors with value of zero for tremor.

Construct the query using the following guidelines:

– Use one part names to reference tables, columns and functions.

– Do not use parentheses unless required.

– Do not use aliases for column names and table names.

– Do not surround object names with square brackets.

Part of the correct Transact-SQL has been provided in the answer area below. Enter the code in the answer area that resolves the problem and meets the stated goals or requirements. You can add code within the code that has been provided as well as below it.

Use the Check Syntax button to verify your work. Any syntax or spelling errors will be reported by line and character position.

Answer: 1 SELECT AVG(NormalizedReading), NearestMountain(SensorID)

2 FROM GroundSensors

3 WHERE TREMOR <> 0 AND NormalizedReading IS NOT NULL

4 GROUP BY NearestMountain(SensorID)

On line 1 Use AVG for the average function.

On line 3 use TREMOR <> 0

On line 4: GROUP BY is a SELECT statement clause that divides the query result into groups of rows, usually for the purpose of performing one or more aggregations on each group. The SELECT statement returns one row per group.

References: https://msdn.microsoft.com/en-us/library/ms177673.aspx

Leave a Reply

Your email address will not be published.