I am pulling a basic query for a new report and have come across this little snag.
I have two tables Buildings
(B) and Pictures
(P) the key that is in both is the BuildingNumber. I have a simple Inner join between the two tables. The problem that I am having is that I have 183 buildings that are in B, but there are multiple pictures for each building, and the number of pictures is not consistent for each building. So when I get the result set, it is returning about 260 rows. What I would like to do is return just one row for each building and have a column for each picture associated with that building. Keep in mind that I do not have the rights to alter or create tables.
My Data is like this:
Building Table (B):
BuildingNumber BldgName Floors SqFt
0001 Science 5 50000
0002 Engineering 4 40000
Picture Table (P):
BuildingNumber PictureURL
0001 URL1
0001 URL2
0001 URL3
0002 URL1
0002 URL2
So my desired result set it like this:
BuildingNumber BldgName Floors SqFt PictureURL1 PictureURL2 PictureURL3
0001 Science 5 50000 URL1 URL2 URL3
0002 Engineering 4 40000 URL1 URL2 NULL