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 IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

count seperate columns

Status
Not open for further replies.

LukeFilms

Programmer
Nov 18, 2005
4
US
I want to have a dash board page that shows the total counts of info from certain columns but just can not get it to work

"SELECT count(*) AS total_rows, count (MovieDvd) as total_dvd where MovieDvd = 1 from dbo.t_contacts "

Total Rows Move DVD Interest

100 64

any ideas

right now i get
Microsoft OLE DB Provider for ODBC Drivers (0x80040E14)
[Microsoft][ODBC SQL Server Driver][SQL Server]Incorrect syntax near the keyword 'from'.
/lfdata/html/dashboard.asp, line 126
 
FROM comes before WHERE...

------
"There's a man... He's bald and wears a short-sleeved shirt, and somehow he's very important to me. I think his name is Homer."
(Jack O'Neill, Stargate)
[banghead]
 
Try this:
Code:
select sum(1) as TotalRows, sum(case when moviedvd = 1 then 1 else 0 end) as Total_DVD
from dbo.t_contacts
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top