Wednesday, May 16, 2012

how to insert a count record column into an existing table

I need to count records from one table and insert that YTD total into a table that I am storing YTD summary totals.

Here is what I tried to do:

SELECT COUNT(members) as YTD_Members_CT FROM dbo.tblMembers
WHERE InputDate between '2011-10-01' and '2012-04-30'

Insert into dbo.YTDSummary (YTD_Members)
values (YTD_Members_CT)

The dbo.tblMembers contains my daily information that I wish to count. I am trying to store the count of members for the time period in another table. I can get the count to appear on the screen with a column name "YTD_Members_CT" but how do I get that count to insert into the other table called dbo.YTDSummary

No comments:

Post a Comment