Get the count using sql query on sql server 2005

Please see the below query. please tell me how to get count using below uery.

thanks
(SELECT DISTINCT   Title, Label, Date
FROM [fnGetTotalDocs]() As TotalDocs
AND not exists
(SELECT Title, Label, Date
       FROM [ReadDocs] As ReadDocs
and TotalDocs.Title=ReadDocs.Title
)
order by Date

Open in new window

Saroj13Asked:
Who is Participating?
 
sangalangaCommented:
SELECT COUNT(DISTINCT   Title)
FROM [fnGetTotalDocs]() As TotalDocs
AND not exists
(SELECT Title, Label, Date
       FROM [ReadDocs] As ReadDocs
and TotalDocs.Title=ReadDocs.Title
)
order by Date
This will give you a count.

Including label and date will give an aggregate error. Try grouping them first.
0
 
Guy Hengel [angelIII / a3]Billing EngineerCommented:
the query, as you showed, is incomplete and incorrect.
apart from that, what should the end-result look like?
0
 
Saroj13Author Commented:
This query is the complete one. I want to dispaly the #
0
 
Guy Hengel [angelIII / a3]Billing EngineerCommented:
I cannot believe this is the full query, at least not for sql 2005:
§  there is no WHERE (just AND alone is a syntax error)
§ no subquery alias (another syntax error)
§  the [] around Date as reserved keyword for column name is missing (might return wrong results)

anyhow:
>I want to dispaly the #

# of what? in regards to the rows returned, the total #?
or per "group" of Title?
or per "group" of Title + label?

please provide sample data with the matching output requested to clarify the request.
0
 
Saroj13Author Commented:
here is the updated query

I am getting teh TotalDocs and Read Docs . Displaying those are not in ReadDocs.
I want the count.
SELECT DISTINCT   Title, Label, DateStamp
FROM [fnGetTotalDocs]() As TotalDocs
WHERE
Title != ''
AND not exists
(SELECT Title ,Label, UserID, DateTimeStamp
       FROM [ReadDocs] As ReadDocs
where UserID='abc'
and TotalDocs.Title =ReadDocs.Title
)
order by DateStamp 

Open in new window

0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.