For this recipe, we'll use ST_Extrude in much the same way we used our own custom-built function in the previous recipe, Constructing and serving buildings 2.5D. The advantage over the previous recipe is that we are not required to have the SFCGAL library compiled in PostGIS. The advantage to this recipe is that we have more control over the extrusion process; that is, we can extrude in all three dimensions.
ST_Extrude returns a geometry, specifically a polyhedral surface. It requires four parameters: an input geometry and the extrusion amount along the X, Y, and Z axes:
DROP TABLE IF EXISTS chp07.buildings_extruded; CREATE TABLE chp07.buildings_extruded AS SELECT gid, ST_CollectionExtract(ST_Extrude(the_geom, 20, 20, 40), 3) as the_geom FROM chp07.building_footprints

And so, with the help of the Constructing and serving buildings 2.5D recipe, we get our extruded buildings, but with some additional flexibility.