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 |
|
sickhead
Starting Member
5 Posts |
Posted - 2002-10-27 : 19:05:44
|
| i need to write a stored procedure to returna table with all days having a count greater 0.my table calendar got the following fields-dte smalldatetime-desc nvarcharand so on...so if there are 5 entries with the dte 20.03.2002 i want the sp toreturn 20 and 5 in one rowany ideas?thxsickheadtoo much of a beautiful thing is wonderful |
|
|
samrat
Yak Posting Veteran
94 Posts |
Posted - 2002-10-27 : 19:31:00
|
| G'dday.UR query would look somethin like this.SELECT [Date], CAST(COUNT(*) AS varchar(30)) + ' ' + CAST(DAY([Date]) AS Varchar(30)) AS NewValueFROM Table1GROUP BY [Date]Regards,Samrat |
 |
|
|
samrat
Yak Posting Veteran
94 Posts |
Posted - 2002-10-27 : 21:46:53
|
| Oops.. shd have read ur question carefully. U want the result set in one for rather then one fieldSELECT COUNT(*) AS DayCount, DAY([Date]) AS Daypart FROM Table1 GROUP BY [Date] you can run this query in your SP!!Cheers,Samrat |
 |
|
|
sickhead
Starting Member
5 Posts |
Posted - 2002-10-28 : 05:50:34
|
| hey Samrat,thx for the quick answer, worx fine...cheerssickheadtoo much of a beautiful thing is wonderful |
 |
|
|
|
|
|