ML_Passion
ML_Passion

Reputation: 1081

How to figure out the column names programmatically using Netezza SQL, where the column values matches a preset value

All,

I have a table like this in netezza. The table has about 30 attributes for different products. I need to find the column names ( in this example column name "attr1" and "attr2") which have "YES" values.

Generally if a column has "YES" as the value, then it would be so for all the rows in the table.

upc upc_desc attr1 attr2 attr3 attr4 attr5
1 cake1 YES NO NO YES
2 cake2 YES NO NO YES
3 cake3 YES NO NO YES
4 cake4 YES NO NO YES
5 cake5 YES NO NO YES
6 cake6 YES NO NO YES

Question: How to figure out the column names programmatically using Netezza SQL, where the column values matches a preset value ?

Thanks !!

Upvotes: 1

Views: 904

Answers (1)

Rishu8
Rishu8

Reputation: 36

Basically you want to transpose data . These kind of questions were already answered in SO.

Transpose rows to columns based on ID column.

Netezza aggregation issue (pivot)

Hope this helps! If you want more help please reply.

Upvotes: 1

Related Questions