Single Choice Easy

QYou have tables named salesTable and salesLine. The salesTable contains the following data:

SalesId RecId

SO0001 1234567

SO0002 1234568

SO0003 1234569

The salesLine table contains the following information:

SalesId RecId

SO0003 2234567

SO0002 2234568

SO0003 2234569

You need to identify the output of the X++ statement:


SalesTable	salesTable;
 SalesLine	salesLine;


while select salesTable
       order by salesLine.Recid desc
	  join salesLine
	  where salesLine.salesId == salesTable.salesid
           
	{
		 info(strfmt("%1",salesTable.salesId));
	}


What should you identify

ID: #9396 Database Manipulation in D365 F&O X++ 182 views
Question Info
#9396Q ID
EasyDifficulty
Database Manipulation in D365 F&O X++Topic

Choose the Best Option

Click any option to instantly check if you're correct.

  • A SO0001 SO0002 SO0003
  • B SO0002 SO0003 SO0003
  • C SO0003 SO0002 SO0003
  • D SO0002 SO0002 SO0003
Correct Answer

Explanation

Justification:

  1. a) The code performs a join between the two tables on SalesID, which means only related records, or records that exists in both locations for that field will be returned. Therefore, we will not see SO0001 in the output.
  2. b) The three sales order IDs are correct, but they are in the wrong order because the order of the selects is based on the record ID on the sales line descending - resulting in SO0003 (highest recID on the lines), then SO0002, then finally SO0003 again (lowest recID on the lines).

  3. c) The code performs a join between the two tables on SalesID, which means only related records, or records that exists in both locations for that field will be returned. Therefore, we will not see SO0001 in the output. We then specify to order the salesLine table in descending order based on the RecID field. The while loop will print the SalesID line by line in that order, which would yield the result: SO0003 SO0002 SO0003.

  4. d) The code performs a join between the two tables on SalesID, which means only related records, or records that exists in both locations for that field will be returned. There is only one sales line with SalesID SO0002.

 

Related Lesson: Data Retrieval

Share This Question

Challenge a friend or share with your study group.

Related MCQ Questions