Forum Replies Created

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

  • RE: Selecting a Value of the Order Within a Group

    declare @tab table

    (

    id int identity(1,1),

    names varchar(100),

    dates datetime

    )

    insert into @tab(names,dates)

    values('student1',DATEADD(day,10,getdate()))

    ,('student1',DATEADD(day,5,getdate()))

    ,('student1',DATEADD(day,15,getdate()))

    ,('student2',DATEADD(day,10,getdate()))

    ,('student2',DATEADD(day,5,getdate()))

    ,('student3',DATEADD(day,11,getdate()))

    ,('student4',DATEADD(day,15,getdate()))

    ,('student4',DATEADD(day,10,getdate()))

    select id,names,dates,inc=pt.inc

    from

    @tab t

    cross apply

    (

    select [inc]= COUNT(1)+1 from @tab pt where pt.id <t.id and...

  • RE: Please help with sql query

    Hi,

    This is another option, if u feel ur Treatment id increments by 11 for each new record.

    SELECT *

    FROM Patient P

    JOIN

    (

    SELECT T1.PatientID,[TreatmentCount]=COUNT(1) from Treatment T1

    LEFT OUTER join Treatment T2 on...

  • RE: Table columns in chronlogical order

    This one is really a good solution. Thanks:-)

  • RE: SQL Server Aggregation Query - Help needed

    Hi this would also help u

    create table #tmp

    (

    Sequences tinyint,

    Product varchar(100),

    Timing datetime,

    Price float

    )

    insert into #tmp(SEQUENCEs,PRODUCT,TIMing,PRICE)

    select 2,'Spoon1','2010-05-05 08:31:01.000',80.00

    union all

    select 3,'Spoon1','2010-05-05...

  • RE: Sql profiler error tracking

    hi everyone,

    After creating server side trace and logging the errors to file, and using

    SELECT *

    FROM ::fn_trace_gettable('C:\ErrorTrace.trc', DEFAULT)

    but the problem is Textdata column shows like "Invalid object name '%.*ls'.",...

  • RE: Sql profiler error tracking

    Thanks for your reply. Helped me a lot. would be implementing server -side trace and appending it to file.

  • RE: SQL error Group by

    Yes all columns except the column which is added in aggregate fn.

  • RE: Stuck with 2 Queries

    Hi Pal,

    try this

    IF EXISTS

    (SELECT * FROM SYS.OBJECTS

    WHERE OBJECT_ID =

    OBJECT_ID(N'[DBO].[MYTABLE]')

    AND TYPE IN (N'U'))

    DROP TABLE [DBO].[MYTABLE]

    GO

    CREATE...

  • RE: SQL error Group by

    HI,

    the problem is that u have not added all columns except the column name inside count function under group by

    .The rule is all columns except the columns related to aggregate...

  • RE: How to order by in this case?

    Very useful Query. Thanks a lot:)

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