Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Rhinorhino on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Cast

Status
Not open for further replies.

mayu03

Programmer
Joined
Oct 3, 2003
Messages
91
Location
US
I have the following query where I am trying to create an extra line with a headers. But I am getting an error msg., because count in header is varchar , but in my select statement is int. How do I fix this problem?

Select 'Report' as 'Report' , 'Count'
Union
Select 'Report',count(*)
from table1
 
Code:
Select 'Report'  as Report , 'Count', 1
Union
Select 'Report',cast(count(*) as varchar(20)),2
from table1
order by 3
 
Select 'Report' as 'Report' , 'Count'
Union
Select 'Report',convert( varchar(20) ,count(*))
from T_REFDATA
Order By 2 Desc

similar to the first post..but didnt use extra column

Parchure Nikhil
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top