Skip to content

Tag: sql

Show all varchar values with PIVOT

I need to show all varchar values with pivot but I’m not sure if that is possible? I have OCCUPATIONS table: Pivot query: Query result: Above query gives only 1 record in each column but I want to get all. Answer You ‘ll need an extra column, e.g. with ROW_NUMBER():

Group by column and multiple Rows into One Row multiple columns

Please help me this: I want to group by column TestType, but Result should be splitted into colunms if they have same TestType I want SQL to return data in this format Result# column should be dynamic because each TestType has many Results Answer As I mention in the comments, what you need here is a PIVOT or …

Efficient way to ignore whitespace in DB2?

I am running queries in a large IBM DB2 database table (let’s call it T) and have found that the cells for column Identifier tend to be padded not just on the margins, but in between as well, as in: ‘ ID1 ID2 ‘. I do not have rights to update this DB, nor would I, given a number of