こんにちは、ねこです。

自称プログラマのおばちゃんのブログです。いろいろあるよねぇ~。

Microsoft MCSA SQL Server 2016 (70-761) むぼーな挑戦 9 恥を承知で本日の間違えたところ投稿

2019-11-06 14:30:21 | 空手

もしも、これを読んでくれる人が英語嫌いだったら、ごめんさなさい。これはあくまでもビールねこの勉強ノートです。ビールねこは日本語も英語も不得手です。。。およよ。

#77

https://www.briefmenow.org/microsoft/solution-you-run-the-following-transact-sql-statement-13/

 
You must insert the following data into the Customer table:
 
You need to ensure that both records are inserted or neither record is inserted.
Solution: You run the following Transact-SQL statement:
『VALUES』のたびに『INSERT INTO』を繰り返さなといけないと思ってました。とほほ。
<答え>YES
 
 
#75
Sales.Customers
Application.Cities
Sales.CustomerCategories
The company’s development team is designing a customer directory application. The application must list
customers by the area code of their phone number. The area code is defined as the first three characters of the
phone number.
The main page of the application will be based on an indexed view that contains the area and phone number
for all customers.
You need to return the area code from the PhoneNumber field.
Solution: You run the following Transact-SQL statement:
インデックス付きVIEWの配下にするには『Schemabinding』をつかえ、ってかいてあるけど、

SELECT @areaCode=LEFT(@phoneNumber,3)としたら『Schemabinding』なしでできるそうな。

<答え>NO *note:TVF can not be used in Indexed View, this is the reason

#74

これも『TOP 1』でリターンを一つにしてないから『NO』

#70

Produces a warning if the credit limit parameter is greater than 7,000
Propagates all unexpected errors to the calling process

<答え>

#68

これわかる人いますか?

Task level is defined using the following rules:

You need to determine the task level for each task in the hierarchy.
Which five Transact-SQL segments should you use to develop the solution? To answer, move the appropriate
Transact-SQL segments from the list of Transact-SQL segments to the answer area and arrange them in the
correct order.
Select and Place:

<答え>どうやらこれが答えらしいですが、ちょっと信じられません。。。

#64

You have the following Transact-SQL query:SELECT
City.CityID,
City.CityName,
TranslateName(Nearby.CityName) AS NearbyCity
FROM Cities AS City
CROSS APPLY NearbyCities(City.CityID) AS Nearby
What type of functions are used in the query? To answer, select the appropriate options in the answer area.
NOTE: Each correct selection is worth one point.
Hot Area:

<答え>Scalar, Table-Vlaued

なんてこった。。。よく読めばわかる問題でした。

SELECT
City.CityID,
City.CityName,
TranslateName(Nearby.CityName) AS NearbyCity ⇐シングルバリューなので、スカラー値
FROM Cities AS City
CROSS APPLY NearbyCities(City.CityID) AS Nearby ⇐『APPLY』をつかっているのでもちろん『Talbe-ValuedFunction』、テーブルで返す値なので、Talbe-Valuedですな。してやられました。

#62

SIMULATION
You work for an organization that monitors seismic activity around volcanos. You have a table named
GroundSensors. The table stored data collected from seismic sensors. It includes the columns describes 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.

もうね、ここまでくればちゃんと読まなあかんなぁ。。。めっちゃ『nearest mountain name』探してて、「なぃ~っ」ってね。

<答え>

SELECT Average(NormalizedReading), NearestMountain(SensorID)
FROM GroundSensors
GROUP BY NearestMountain(SensorID)
WHERE TREMOR IS NOT 0 AND NormalizedReading IS NOT NULL

<ねこの間違った答え>

Select ①AVG(NormalizedReading) ②as AverageOfNomalizedReading, NearestMountain(SensorID) ②as NearestMountain
from GroundSensors
where ③Tremor <> 0 and NormallizedReading IS NOT NULL
④Group By NormalizedReading, SensorId

①AVGはつかえません。
②エリアスをつかえといってません。
③これはこのままでもいいのかなぁ。。。テスト中にシンタックスのチェックができたはず。
④GroupByでは『NearestMountain(SensorID)』のスカラー値の返り値でグループ化してやらないといけない。それに、『Average』はグループ化されたものの集計・平均値だから、ここでは『スカラー値の返り値』がグループ化によって基となって平均値を出さなければならない。
 
#57
You need to create a query that lists all complaints from the Complaints table, and the name of the person
handling the complaints if a person is assigned. The ComplaintID must be displayed first, followed by the
person name.
Construct the query using the following guidelines:Use two-part column names.
Use one-part table names.
 
<答え>
SELECT Complaints.ComlaintID, Persons.Name
FROM Persons
JOIN Contacts
ON Persons.PersonID=Contacts.PersonID
JOIN Complaints
ON Contacts.ComplaintID=Complaints.ComplaintID
 
<ねこの答え>間違っているとは限らない!!!
SELECT Complaints.ComplaintID, Persons.Name
FROM Complaints
LEFT OUTER JOIN Contacts ON Complaints.ComplaintID = Contacts.ComplaintID
LEFT OUTER JOIN Persons ON Contacts.PersonID = Persons.PersonID
なぜなら、『all complaints from the Complaints table』って書いてあったから。
Peterさんいわく、『「すべてのcomplaints 」って書いてあるから、これがベーステーブルになってFROMで呼ばれる。(そして「もしも」Personが任命されていれば名前を出すように。)そしてもしPersonが任命されてて、名前がNULLだった場合、以下のようにかかなきゃね。』って。
『Answer is wrong!As we have to show all complaints (“You need to create a query that lists “all” complaints from the Complaints table, and the name of the personhandling the complaints “if” a person is assigned.”) the table complaints has to be the base table. And, in case a person is assigned, also the persons name has to be shown but the persons name may be NULL. Hence the statement needs to look like:』って書いてるよ。https://www.briefmenow.org/microsoft/you-need-to-create-a-query-that-lists-all-complaints-fr/
 
 
 さて、明日は全然覚えてない「OUTPUT」のビデオみます。
NetlifyとGatsby、なかなか進まないなぁ。。。