show only those columns which have data value
Posted
by
Zankar
on Stack Overflow
See other posts from Stack Overflow
or by Zankar
Published on 2011-01-04T07:45:44Z
Indexed on
2011/01/04
7:53 UTC
Read the original article
Hit count: 211
sqlquery
I don't known that it is possible or not but i want to ask a question to you as suppose i have a table as
table1
id | mon | tue | wed | thu | fri | sat | sun
1 | 100 | 200 | 0 | 0 | 0 | 0 | 0
2 | 200 | 0 | 300 | 0 | 0 | 0 | 0
So from given table result should be ...
id | mon | tue | wed |
1 | 100 | 200 | 0 |
2 | 200 | 0 | 300 |
as shown in table1 different columns of week.
If all values in a column is 0 or null then query should ignore to show that column(as shown in result)
Note: if we run a query as select * from table1
it shows all columns.
While I don't wants a query like select id,mon,tue,wed from table1
because no. of showing columns may change.
Please reply to me.
Thank you....
© Stack Overflow or respective owner