Forum Replies Created

Viewing 15 posts - 5,986 through 6,000 (of 6,036 total)

  • RE: Sum and Group by

    GROUP BY (Number_of_the_week - 1)/3

    GROUP BY (Number_of_the_week - 1)/6

  • RE: Group By Week

    result_date - DATEPART (dw, result_date) + 1

    This is made for @@DATEFIRST = 1 (Monday is first day of the week)

    Check your server settings.

  • RE: Group By Week

    groub by DATEDIFF(ww, result_date, getdate())

    getdate() may be replaced with any given date. For example, '1900-01-01 00:00'.

    Anyway difference in weeks between that date and dates for all same week tasks will...

  • RE: Top value

    I forgot to change alias in GROUP BY for nested query.

    This must work:

    SELECT MAX(l.clrec_sysid), l.cons_entity_id, lm.Max_event_date

    FROM tblclinical_record_master l

    INNER JOIN tblcase c ON l.case_sysid = c.case_sysid

    INNER JOIN (SELECT l1.cons_entity_id,MAX(l1.event_date) as Max_event_date

    FROM...

  • RE: Help in UPDATE

    If createddttm is datetime then it is not in any format.

    Format is used only for date representation.

    The strict rule is:

    Put clustered index on the column you most often use...

  • RE: sortorder on varchar datatype column containing numeric values

    Lets say that your column data type is varchar(50).

    In such case it gonna be:

    ORDER BY case when ISNUMERIC(ColumnName) = 1 then REPLICATE ('0', 50 - LEN(LTRIM(ColumnName))) + LTRIM(ColumnName) else ColumnName...

  • RE: Query

    DECLARE @Query varchar(8000), @DBName varchar(20)

    SET @DBName = 'A' -- or 'B' or 'C', it should be parameter for your SP

    SET @Query = 'SELECT DISTINCT K.MAXCOM_ID FROM ' + @DBName +...

  • RE: Help in UPDATE

    Column doc.CreatedDtTm participates in multiple joins "between ... and ..."

    Is there clustered index on this column? It should be.

  • RE: Top value

    SELECT MAX(l.clrec_sysid), l.cons_entity_id, lm.Max_event_date

    FROM tblclinical_record_master l

    INNER JOIN tblcase c ON l.case_sysid = c.case_sysid

    INNER JOIN (SELECT l1.cons_entity_id,MAX(l1.event_date) as Max_event_date

    FROM tblclinical_record_master l1

    GROUP BY l.cons_entity_id) lm on l.cons_entity_id = lm.cons_entity_id

    and l.event_date = Max_event_date

    WHERE...

  • RE: Column Naming Conventions (rears it''''s ugly head again :)

    I don't remember now where I've read it. It was not only source.

    But I know that optimizer takes column name from query and searches all tables mentioned in the query...

  • RE: need help to delear time

    Strange error.

    Probably you forgot about quotes.

    declare @StartTime dateTime

    set @StartTime = '20:30'

    works absolutely fine.

  • RE: Column Naming Conventions (rears it''''s ugly head again :)

    Using table name in column name does not make any sence.

    If you want to which table this column belongs to you can write TableName.ColumnName instead of TableNameColumnName.

    First option makes optimizer...

  • RE: Disappearing Tables

    INSTEAD OF DELETE trigger is good idea.

    You can also create dummy table with FK relation to PK of your table. This will block any attempt to delete rows from the...

  • RE: trigger on view

    Freaky Dutch English...

    But if you have any SELECT statement in your application???

    Dynamic SQL is your choice???

    I've forgotten somebody uses access data by "SELECT...

  • RE: find difference between dates - help~~

    Try this:

    select DT.Thedate, DT.Value, DT.Value - T3.Value as Delta

    FROM  (Select t1.thedate, T1.Value, max(t2.thedate) as PrevDate

               from MyTable T1

               left join MyTable T2 on t1.thedate > t2.thedate

               group by t1.thedate, T1.Value)...

Viewing 15 posts - 5,986 through 6,000 (of 6,036 total)