Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
| Author |
Topic |
|
JMOE
Starting Member
4 Posts |
Posted - 2011-03-16 : 15:19:00
|
| Hello All. having some issue with my statment and/or import.using a statment to count the number of rows by type and then format the count of rows into a number.Issue Im having is when i load my sql statment into excel and run my query, the count of row column comes down as a text, which i have to format into number to be able to pivot table the data. but when i refresh my query, the row count column reverts back to a text (general) format and lose the ability to use my pivot table.is there a way to code my sql statment so the row count is allready cast as interger when i run my query in excel or is there a way in excel to keep the column format as number.SELECT A.AsofDate,datename(weekday,DATEPART(weekday,AsofDate))as Weekday,A.NAME as List,cast(COUNT(NAME) as int)AS ListcountFROM [x].[dbo].[x] as AWhere AsofDate>=DateAdd(day, DateDiff(day,0,getdate()),-30)group by A.AsofDate,A.NAMEorder by AsofDate asc |
|
|
X002548
Not Just a Number
15586 Posts |
|
|
jimf
Master Smack Fu Yak Hacker
2875 Posts |
Posted - 2011-03-16 : 15:32:57
|
| This is an Excel issue. You don't need to cast count to int since it already is an int. Try Count(*) * 1 and see if that fools Excel into doing the right thing.JimEveryday I learn something that somebody else already knew |
 |
|
|
JMOE
Starting Member
4 Posts |
Posted - 2011-03-16 : 15:47:43
|
| jimfYOUR AWESOME :)FIXED..COUNT(NAME) * 1 AS Listcountthanks so much |
 |
|
|
X002548
Not Just a Number
15586 Posts |
|
|
|
|
|
|
|