Click here to Skip to main content
15,916,527 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
Hi guys
i want to select count from database
this is table

SQL
USE [Agency]
GO

/****** Object:  Table [dbo].[productivity_Tb]    Script Date: 10/06/2013 01:17:48 ******/
SET ANSI_NULLS ON
GO

SET QUOTED_IDENTIFIER ON
GO

CREATE TABLE [dbo].[productivity_Tb](
    [ID] [int] IDENTITY(1,1) NOT NULL,
    [Date1] [datetime] NULL,
    [Month1] [int] NULL,
    [Collector] [nvarchar](max) NULL,
    [CM_ID] [int] NULL,
    [ACC_NO] [int] NULL,
    [Balance] [money] NULL,
    [BKT] [nvarchar](255) NULL,
    [Call_Visit] [nvarchar](255) NULL,
    [Trials] [nvarchar](255) NULL,
    [PTP_Type] [nvarchar](255) NULL,
    [PTP_Date] [date] NULL,
    [PTP_Amount] [money] NULL,
    [PTP_Kep_Broken] [nvarchar](255) NULL,
    [Kept_Amount] [money] NULL,
    [feedback] [nvarchar](255) NULL,
    [New_Address] [nvarchar](255) NULL,
    [NEW_MOBIL] [int] NULL,
    [Area] [nvarchar](255) NULL,
    [Officer] [nvarchar](255) NULL,
    [Agency] [nvarchar](255) NULL,
    [situation] [nvarchar](255) NULL,
 CONSTRAINT [PK_productivity_Tb] PRIMARY KEY CLUSTERED
(
    [ID] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
) ON [PRIMARY]

GO


now i want to get count of Collector between date1 = "" and date1 ="" but i want it to didnot calculate the repeat Collector order by date1

i need this query
Posted
Comments
RedDk 5-Oct-13 19:34pm    
SELECT COUNT(*) FROM [Agency].[dbo].[productivity_Tb] WHERE [Date1] = (the date parameters), no?

SQL
select distinct [Collector],count(Collector) as NumberOfCollectors FROM productivity_Tb WHERE Date1 BETWEEN '2013-01-31' AND '2013-08-01' group by [Collector]
 
Share this answer
 
Comments
Ahmed Emad 6-Oct-13 10:46am    
Thanks its work as well
Try:
SQL
SELECT COUNT(*) FROM productivity_Tb WHERE Date1 BETWEEN '2013-01-31' AND '2013-08-01'
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900