exam questions

Exam 70-761 All Questions

View all questions & answers for the 70-761 exam

Exam 70-761 topic 1 question 105 discussion

Actual exam question from Microsoft's 70-761
Question #: 105
Topic #: 1
[All 70-761 Questions]

Note: This question is part of a series of questions that use the same or similar answer choices. An answer choice may be correct for more than one question in the series. Each question is independent of the other questions in this series. Information and details provided in a question apply to that question.
You have a database for a banking system. The database has two tables named tblDepositAcct and tblLoanAcct that store deposit and loan accounts, respectively. Both tables contain the following columns:

You need to determine the total number of deposit and loan accounts.
Which Transact-SQL statement should you run?

A.

B.

C.

D.

E.

F.

G.

H.

Show Suggested Answer Hide Answer
Suggested Answer: C
Would list the customers with duplicates, which would equal the number of accounts.
Incorrect Answers:
A: INTERSECT returns distinct rows that are output by both the left and right input queries operator.
B: Would list the customers without duplicates.
D: Number of customers.
F: EXCEPT returns distinct rows from the left input query that aren't output by the right input query.
References:
https://msdn.microsoft.com/en-us/library/ms180026.aspx

Comments

Chosen Answer:
This is a voting comment (?). It is better to Upvote an existing comment if you don't have anything to add.
Switch to a voting comment New
mattia_88
Highly Voted 5 years, 8 months ago
" total number of deposit and loan accounts" is correct answer C (UNION ALL)
upvoted 20 times
...
Andi64
Highly Voted 5 years, 4 months ago
if a customer has 3 deposit accounts then the query <select custno from deposit > returns this custno 3 times, that means, you count the total number of records. I think, answer C) with union all statement is ok
upvoted 6 times
...
Vermonster
Most Recent 4 years, 5 months ago
C is absolutely correct
upvoted 1 times
...
Andy7622
4 years, 6 months ago
C is correct . custno and acctno are unique in both tables so we don't have to exclude distinct values for custno. that means we must use UNION ALL. Then we count rows in result set of Union All
upvoted 1 times
...
HA2020
4 years, 7 months ago
None of them is correct.
upvoted 1 times
...
kiri2020
4 years, 8 months ago
select count(AcctNo) as TotalAccounts from tblDepositAcct UNION select count(AcctNo) as TotalAccounts from tblLoanAcct
upvoted 1 times
...
Oooo
4 years, 9 months ago
We need total deposit and loan accounts.A single person can have multiple accounts. So in deposit table if Customer1 has 3 accounts, then all these accounts are going to be unique, the same accounts cannot exist in Loan table so option A is wrong it will return zero records. Coming to B again if Customer1 has 3 accounts in deposit table and 2 accounts in Loan table, for customer1 itself there are total 5 accounts but if you do Union on Custno you will get only 2 as the result which is wrong if we need total account numbers. Coming to C again if Customer1 has 3 accounts in Deposit table and 2 accounts in loan table that means in Deposit table there are 3 entries of Customer1 in deposit and 2 in Loan so union all will display all 5 because union all displays everything including dupes. Rest options are not relevant here. So the correct answer is C
upvoted 2 times
...
Backy
5 years ago
C is correct, it counts all rows in tblDepositAcct and all rows in tblLoanAcct, each row has unique AcctNo CustNo is irrelavant because the question asks for unique AcctNo even some may belong to the same CustNo
upvoted 1 times
...
Anette
5 years, 1 month ago
its C for Sure. Tested
upvoted 1 times
Anette
5 years, 1 month ago
BUT if there is case when loan acc no is the same with deposit acc no then the answer is G. But as I know loan and deposit acc numbers are different in banks for one customer number.
upvoted 1 times
Anette
5 years, 1 month ago
Sorry H** instead of G :)
upvoted 1 times
...
...
...
Barbedx
5 years, 4 months ago
So, there are C and H answers are correct, agree with mattia_88 and Andi64 both are rights, and both query will return equivalent answers
upvoted 1 times
Anette
5 years, 1 month ago
What if by chance loan account number is the same with deposit account number, what happens? It counts only once in H and twice (correct) in C, so the anwer is C in my opinion
upvoted 1 times
...
...
anonimdom
5 years, 5 months ago
A doesn't count accounts which present only in one table, C counts users, if we want to count all accounts (not only intersection), the correct answer might be H.
upvoted 2 times
SlazericeQ
5 years, 5 months ago
we need to count all accounts, so that means count all rows in both tables (one user can have more accounts). Therefore we need to use UNION ALL, so C seems as right answer to me. Tested as: declare @Dep as table ( cust smallint not null primary key, acc smallint null ) insert into @Dep values (1,45),(2,47),(3,78) declare @Loan as table ( cust smallint not null primary key, acc smallint null ) insert into @Loan values (1,33),(3,35) select * from @Dep select * from @Loan select count(*) from( select d.cust from @Dep as d union all select l.cust from @Loan as l ) as R
upvoted 6 times
anonimdom
5 years, 4 months ago
But, your query selects cust, not acct. If each cust has only one acct then it looks correct. If a cust has more than one acct, then it looks like it counts a wrong columns.
upvoted 4 times
fifkus
4 years, 5 months ago
The only answer that uses acct (A) is wrong. Out of available answers, only C is correct as - even though you use cust instead of acct, UNION ALL is used (which doesn't exclude duplicates). COUNT also doesn't exclude duplicates, so even if you're calculating on (non-unique) cust column, you still end up with a correct answer.
upvoted 1 times
...
...
RachelT
4 years, 6 months ago
Thank you, I tested it and worked.
upvoted 1 times
...
...
...
mlourinho
5 years, 7 months ago
» deposit and loan accounts, meaning ACCOUNTS that are in the table deposit and the table accounts. Also, the question demands ACCOUNTS not Customers. So yes, A is the correct answer.
upvoted 1 times
...
dragan
5 years, 9 months ago
A is correct answer.
upvoted 1 times
dragan
5 years, 9 months ago
Sorry it is ok. "total number of deposit and loan accounts" not both
upvoted 2 times
...
imran
5 years, 8 months ago
cant be A FOR SURE
upvoted 4 times
...
...
Community vote distribution
A (35%)
C (25%)
B (20%)
Other
Most Voted
A voting comment increases the vote count for the chosen answer by one.

Upvoting a comment with a selected answer will also increase the vote count towards that answer by one. So if you see a comment that you already agree with, you can upvote it instead of posting a new comment.

SaveCancel
Loading ...