views:

65

answers:

3

i need to take all data if Page!=@page, get AllDATA

select count(page) as TARIH,
(datepart(hour,Date)*60+datepart(minute,Date))/@countgap as SIRA
from scr_SecuristLog
where Date between @date1 and @date2 and Page=@page or Page = AllDATA

+1  A: 

try:

select
    count(page) as TARIH
        ,(datepart(hour,Date)*60+datepart(minute,Date))/@countgap as SIRA
    from scr_SecuristLog
    where Date between @date1 and @date2 and (Page=@page or Page = AllDATA)
KM
A: 

Solution: select count(page) as TARIH,
(datepart(hour,Date)*60+datepart(minute,Date))/@countgap as SIRA
from scr_SecuristLog
where Date between @date1 and @date2 and (Page=@page or @page='Tüm Kullanıcılar')

Phsika
that is what I said 44 minutes ago! you need ( ) around your OR condition
KM
A: 
select count(page) as TARIH,
(datepart(hour,Date)*60+datepart(minute,Date))/@countgap as SIRA
from scr_SecuristLog
where 
    Date between @date1 and @date2 
    and 
    (
     (@page is not null and Page=@page) 
     or (@page is null and @page=@page)
    )

will return all data between date1 and date2 and only data equal to the parameter, or if the parameter is null will return all data between date1 and date2

DForck42