sql - Select Count(Distinct Value) returns 1 -


I am preparing a query in 2005 which looks something like this:

  SELECT COUNT (separate column name) from the table where the call is not named  

When I run the query with COUNT (), this value returns 1. When I run it without COUNT () , Then the SSMS report is correct, such as 212 records.

The column datatip in question is of numerical (16, 0).

For those people who can ask, the query is completely:

vnrolment at vEmployers INNER from SELECT COUNT (DISTINCT O_ID) O_ID = E_EnrolmentEmployer WHERE E_START & gt ; = '01 -AUG-2008 'and' E_START & lt; '01-AUG-2009 'and' O_ID 'are not in zero and O_ID (select O_ID from vEmployers on Violomment OIID = E_EnrolmentEmployer WHERE E_Start & lt; '01 -AUG-2008' and e_start> gt; = '01 -AUG-2007 ')

This query basically gives a professional shape to repeat between the two 12 months period.

So I'm surprised that "COUNT (separate column name)" 1 is specifying "when the column name is not null"?

Here is a sample of data when SELECT TOP 10 DISTINCT is run by the column name ... etc ...

  1346116 1346131 1346425 1346923 1349 935 1350115 1350153 2594787 2821944 2879631   

Using numerical (16, 0) I suspected that this data type was related . To add an INT type, add a cast to the COUNT section:

  calculation (separate cast (O_ID as Int))  

Comments

Popular posts from this blog

sql - dynamically varied number of conditions in the 'where' statement using LINQ -

asp.net mvc - Dynamically Generated Ajax.BeginForm -

Debug on symbian -