I need to group by ,even if is there a difference in values for a column by converting to a text value and needs that text value to be included in select list
How is this possibe?
SELECT col1,col2
FROM
(
SELECT col1,col2 FROM table1
UNION ALL
SELECT col1,col2 FROM table2
UNION ALL
SELECT col1,col2 FROM table3
)tbl
GROUP BY tbl.col1
,tbl.col2
here col2 may or may not be a text value or int, if it is text value i need to convert all other col2 ints to text and do a group by
See this example :
Table 1
-------
A B 3 C
A B var C
Table 2
-------
UNION ALL
B B 3 C
B B var C
Table 3
-------
UNION ALL
B B 3 C
B B 3 C
Result of each table should be
-------
Table 1
-------
A B var C (since there is a var in the any of the row in that column in that table)
Table 2
-------
B B var C (since there is a var in the any of the row in that column in that table)
Table 3
-------
B B 3 C (here it remains 3 since there is not value call var in any of the row in that column)
Result
------
A B var C
B B var C (since there is a var in the any of the row in that column in that table)