Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2000 Forums
 SQL Server Development (2000)
 count

Author  Topic 

cool.mugil
Starting Member

32 Posts

Posted - 2008-04-16 : 06:48:07
hai,
my table structure is as follows,
mon tue wed thu fri sat sun
1 2 0 0 1 3 4

i need to count how many times zero occurs between the given two dates.say for example i need to count how many times zero occur between 01/04/2008 to 31/04/2008.
thanks in advance

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2008-04-16 : 06:53:57
where are the dates stored? i can see only day info in your table.
Go to Top of Page

cool.mugil
Starting Member

32 Posts

Posted - 2008-04-16 : 07:04:28
i does not have dates stored.it have only day info.it is the problem
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2008-04-16 : 07:10:29
What does those figure suggest? is it for a period like month, week ..?
Go to Top of Page

cool.mugil
Starting Member

32 Posts

Posted - 2008-04-16 : 07:22:16
it is for a week
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2008-04-16 : 07:30:47
then how would you distingusih which rows correspond to which week?
Go to Top of Page

cool.mugil
Starting Member

32 Posts

Posted - 2008-04-16 : 07:39:57
sorry.it is for a month.my table will be as follows,
my table structure is as follows,
mon tue wed thu fri sat sun date
1 2 0 0 1 3 4 01/04/2008
Go to Top of Page

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2008-04-16 : 08:43:44

Somwthing like


select date,count(val) as val from
(
select date,mon as val from table
union all
select date,tue as val from table
union all
select date,wed as val from table
union all
select date,thu as val from table
union all
select date,fri as val from table
union all
select date,sat as val from table
union all
select date,sun as val from table
) as t
where val=0
group by date



Madhivanan

Failing to plan is Planning to fail
Go to Top of Page
   

- Advertisement -