I need an SQL Server query that will list the select rows from the first table and list the related records from the second table on the same row as the first table record.
Here is the dataset from the first table
tblName
NID Name
1 John Doe
2 Jane Doe
Here is the dataset from the second table
tblTask
TID Task EstMin NID
1 Fix the bed 45 1
2 Clean room 30 1
3 Wipe the floor 20 1
4 Cook breakfast 45 2
5 Clean the dishes 30 2
The NID columns on both tables relate to them. I need a query that will generate the dataset below
Result dataset
NID Name Task EstMin Task EstMin Task EstMin
1 John Doe Fix the bed 45 Clean room 30 Wipe the floor 20
2 Jane Doe Cook breakfast 45 Clean the dishes 30
1条答案
按热度按时间jdgnovmf1#
You can use conditional aggregation as follows: