Forum Replies Created

Viewing 15 posts - 271 through 285 (of 321 total)

  • RE: Max of date from multiple columns

    A little more better...

     

    DECLARE @MyTable TABLE

    (

    myVersion    VARCHAR(10),

    LastDateA     DATETIME,

    LastDateB     DATETIME,

    LastDateC     DATETIME

    )

    INSERT @MyTable VALUES ('VERSION A', '01/01/2004', '02/01/2004', '01/03/2004')

    INSERT @MyTable VALUES ('VERSION A', '03/01/2004', '02/04/2004', '01/09/2004')

    INSERT @MyTable VALUES ('VERSION A', '04/01/2004', '04/09/2004',...

  • RE: Simple deuping

    This will work for ANY No of duplicates and will keep the first row with the MIN(ID)

     

    SET NOCOUNT ON

    DECLARE @theatre TABLE

    (

    [ID] INT IDENTITY,

    LastName VARCHAR(25),

    FirstName VARCHAR(25)

    )

    INSERT INTO @theatre (LastName, FirstName) VALUES...

  • RE: Problem w/ Grouping & Count

    You get Null because you select NULL : )

    Null As 'HireCnt'   

    Null As 'ApplicantCnt'

    About the numbers they might be correct. It seems that 1 row gives...

  • RE: temp tables in nested sproc

    For someone to be able to help you should provide the tables and sample data with the req result.

    From my undertanding (which can be wrong ) if you transform your...

  • RE: View Performance with union

    CREATE VIEW Contact

    AS

    SELECT id, id as Client,'Client' as Type, Name,

    FROM Client

    UNION ALL
    SELECT id, id as Nurse, Type, [Name],

    FROM Nurse

     
     
    took out the NULL's wich don't make sense for you.
     
    I don't know why you keep "id as...
  • RE: Latest value

    SELECT AAA.OD_ID,Op_Sec_ID,Op_Val_Date,Sec_Date,Sec_Price

    FROM

    #tblOP AAA INNER JOIN

    (SELECT OD_ID,MIN(MyNmb) MyDiff

    FROM

    (SELECT A.Od_Id,A.Op_Sec_Id,A.Op_Val_Date,B.Sec_ID,B.Sec_Date,B.Sec_Price,  CASE WHEN A.Op_Val_Date>B.Sec_Date THEN CAST(A.Op_Val_Date as int)-CAST(B.Sec_Date as int) ELSE CAST(B.Sec_Date as int)-CAST(A.Op_Val_Date as int) END MyNmb

    FROM #tblOP A inner join #tblSecurity...

  • RE: How to Stop Multiple Combination in Self Join

    Won't work to have 4 derived tables.

    The solution is based on comb of two diff sets.

    so if C,N,Y,O form 2 sets the sol will work

    ex: C,N can be combined...

  • RE: How to Stop Multiple Combination in Self Join

    The catch is to label the rows for each DATA and ID2 with Ordered Numbers and match the rows with diff ID2 but the same Data and RowNumber

  • RE: need help with this report

    Hmm

    what if you change the design of the table

    StartPeriod---DateTime

    EndPeriod ---DateTime

    Status ----Available/NotAvailable

    and when you insert a new row upgrade EndPeriod check the status on last row and if different add...

  • RE: How to Stop Multiple Combination in Self Join

     

     

    SET NOCOUNT ON

    DECLARE @T Table (ID int, ID2 char(1) , Data varchar(10))

    insert into  @T (ID,ID2,Data) Values(1,'N','Data')

    insert into  @T (ID,ID2,Data) Values(2,'N','Data' )

    insert into  @T (ID,ID2,Data) Values(3,'C','Data' )

    insert into  @T (ID,ID2,Data) Values(4,'C','Data5'...

  • RE: Sql query i think using rollup or cube???????

    UPS ya I was missing 20 and 30 ... didn't notice (Thks Remi : ) )

    for the (10,a) pair I SAID the sol is not working... he needs to check...

  • RE: Sql query i think using rollup or cube???????

    At least (ID,Country) has to be key for the Solution to work.

    Otherwise one more step need to be added to treat this rows depending on FirstName...

     

    set nocount on

    create table #t(IdRow...

  • RE: Sql query i think using rollup or cube???????

    If you have a KEY on your table you can achieve what you want otherwise it won't work (like here where IdRow is not a Key...).

    set nocount on

    create table...

  • RE: Output Parameters for a newbie

    SET QUOTED_IDENTIFIER OFF

    SET NOCOUNT ON

    DECLARE @SumOfMaximums FLOAT, @DataValue FLOAT, @PreviousDataValue FLOAT, @SeqNo INT,@Tid INT, @MaximumValue FLOAT

    SET @Tid=11

    CREATE TABLE [#TRENDDATA] ( [SEQUENCENUMBER_] [int] NOT NULL ,

     [TID_] [int] NOT NULL ,

     [DATE_STAMP_]...

  • RE: date time

    SELECT CASE WHEN Step1 IS NULL THEN 0 ELSE 1 END

    This will return the row as integer.

    In your case it shows 1/1/1900 because it transforms that integer 0...

Viewing 15 posts - 271 through 285 (of 321 total)