Forum Replies Created

Viewing 5 posts - 1 through 5 (of 5 total)

  • RE: CASE statement rpoblem

    CASE when datediff(day,a.dteTeslimTarihi,b.OnayTarihi)>0 Then 2 else 0 end

  • RE: Select distinct ... order by newid()

    This is my solution:

    declare @A1 int

    declare @i int

    set @i=0

    create table #result (A1 int ,A2 int,A3 varchar(100))

    DECLARE cursorrr CURSOR FOR

    select a1 from test order by newId()

    OPEN cursorrr

    FETCH NEXT...

  • RE: A Set-Based solution instead of multiple passes?

    that is my solution

    select distinct s1.MIS,'only' + '-' + case when type=1 then 'medical' else 'therapy' end State

    from #serv s1

    where not exists (select 1 from #serv s2 where s1.MIS=s2.MIs and...

  • RE: Display max value for all rows within group

    select t1.date,t1.store,t1.trans_number,t1.prod_number

    ,case when maxrandom=2 then 2 else random end as random

    from Mytable t1

    ,(select date,store,trans_number,max(random) maxrandom from Mytable group by date,store,trans_number ) tempTable

    where t1.date=tempTable.date and t1.store=tempTable.store and t1.trans_number=tempTable.trans_number

  • RE: Finding Current Month's First Day& Last Day

    declare @Year int

    declare @Month int

    select @Year=datepart(year,getdate()),@Month=datepart(month,getdate())

    declare @NextMonth int

    if @Month<>12

    set @NextMonth=@Month+1

    else

    set @NextMonth=1

    select convert(datetime, convert(char(4),@Year)+right('0'+convert(varchar,@Month),2)+'01')FirstDay

    ,dateadd(d,-1,convert(datetime,convert(char(4),@Year)+right('0'+convert(varchar,@NextMonth),2)+'01'))LastDay

Viewing 5 posts - 1 through 5 (of 5 total)