UiADPv1 Exam QuestionsBrowse all questions from this exam

UiADPv1 Exam - Question 55


Considering that the attached table is stored in a variable called "dt":

Which LINQ query can be used to return the maximum total Quantity?

Show Answer
Correct Answer: C

To determine the maximum total Quantity, it's important to consider the total quantity of each item, not just the maximum value in the Quantity column. Option C performs a GroupBy operation on the 'Item' column and then calculates the sum of quantities for each item. It then finds the maximum sum among these grouped sums, which represents the maximum total quantity of any single item type in the table. This approach correctly addresses the requirement of finding the maximum total Quantity, considering all instances of each item.

Discussion

7 comments
Sign in to comment
Brandon00777Option: A
Feb 21, 2024

The answer is A. I tested it in studio, it returned the value of 80. Which is the largest value in the "Quantity" column

Brandon00777Option: C
Feb 26, 2024

Correction: C seems to be correct, since the groupby function literally groups interrelated data and the sum function is self-explanatory.

ChoudayyaOption: C
Feb 28, 2024

Both options A and C are giving 80 as output. I tested in studio.

milindkumarOption: A
Feb 29, 2024

A is correct as tested in studio.

milindkumarOption: A
Feb 29, 2024

Both options A and C are giving 80 as output. I tested in studio.

kingkayyOption: C
Apr 17, 2024

The question is quite tricky. We are going to get 80 for both option A and C but here is why C is right. The question is asking for the maximum of the total quantities. In this case, option A just gives as the maximum individual quantity in the quantity column which is Kiwi giving 80. In the case of option C, which answers the question, it groups each of the quantity of items(apple, orange, mango, kiwi, pear). It goes ahead to sum them (apple - 10+5+12=27, orange-20, mango-5+15=20,kiwi=80,pear=1). It finds the maximum of the sums (27, 20, 20, 80, 1). In this case, 80 is the maximum of the total quantities.

BenAndBen
Jul 18, 2024

but the question is only ask for the maximum total quantity and it does not indicate to group and sum per item.

BenAndBenOption: A
Jul 18, 2024

Answer is A.