Link to home
Start Free TrialLog in
Avatar of Saroj13
Saroj13

asked on

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

Avatar of Guy Hengel [angelIII / a3]
Guy Hengel [angelIII / a3]
Flag of Luxembourg image

the query, as you showed, is incomplete and incorrect.
apart from that, what should the end-result look like?
Avatar of Saroj13
Saroj13

ASKER

This query is the complete one. I want to dispaly the #
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.
ASKER CERTIFIED SOLUTION
Avatar of sangalanga
sangalanga

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Saroj13

ASKER

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