Forum Replies Created

Viewing 15 posts - 301 through 315 (of 898 total)

  • RE: Compare data between rows of same table

    One more way to do this..

    ; WITH cte_Temp1 AS

    (

    SELECTT1.*, T2.mytab1col1 AS mytab1col1_T2

    FROM##Temp1 AS T1

    CROSS JOIN(

    SELECTDISTINCT T2.mytab1col1

    FROM##Temp2 AS T2

    ) AS T2

    )

    SELECTT1.mytab1col1, T1.mytab1col1_T2

    FROMcte_Temp1 AS T1

    LEFT OUTER JOIN##Temp2 AS T2 ON T1.mytab1col1_T2 =...

  • RE: How To Sum...

    You will probably need a trigger which will update the value of the 3rd column when you enter or update a row in your table.

  • RE: Parent-Child But Not All Have Children...?

    Something like this

    DECLARE@tbl_Customer TABLE

    (

    Customer_idINT,

    ValueNUMERIC(18,2)

    )

    DECLARE@tbl_Relation TABLE

    (

    Customer_idINT,

    Child_idINT

    )

    INSERT@tbl_Customer

    SELECT1, 100 UNION ALL

    SELECT2, 150 UNION ALL

    SELECT3, 1000 UNION ALL

    SELECT4, 300 UNION ALL

    SELECT10, 120 UNION ALL

    SELECT11, 150 UNION ALL

    SELECT12, 1000 UNION ALL

    SELECT13, 200

    INSERT@tbl_Relation

    SELECT1, 10 UNION ALL

    SELECT1,...

  • RE: How to get zero values for a row

    You can create a table variable or a temporary table holding all the months and then do a LEFT OUTER JOIN with this table

    DECLARE@tblCalendar TABLE

    (

    Month_NameVARCHAR(20),

    Month_NumTINYINT,

    Year_NumSMALLINT

    )

    INSERT@tblCalendar

    SELECT'January', 1, 2013...

  • RE: how to convert the below subquery to joins

    Something like this

    SELECTH.CtryId, H.WrkflwId, H.Dt

    FROMstepHistory H

    INNER JOIN(

    SELECTWrkflwId, ctryId, MAX( DtTm ) AS DtTm

    FROMstepHistory

    GROUP BY WrkflwId, ctryId

    ) AS SH ON H.WrkflwId = SH.WrkflwId AND H.CtryId = SH.CtryId AND H.DtTm = SH.DtTm

    WHEREH.SteTyId...

  • RE: get overtime hours

    sugiarttampubolon (4/18/2013)


    i am sure the data is decimal(6,3)..

    the detail is make a store procedure from 2 database

    master_db and temporary_db but i cannot touch the source program just make stored procedure...

  • RE: get overtime hours

    Decimals are not a good data type to store time

    You have given 06:20 and 19:00 as sample data which doesn't look like decimals

    Are you sure the data type is decimal...

  • RE: Asking for Interview Questions

    I would help the OP if I feel the person has taken some effort in trying to find answers themselves and is not plain lazy.

    I have found numerous posts where...

  • RE: Rewrite query using LEFT JOIN

    This should do the work for you

    SELECTCASE WHEN C.active_flag = 1 THEN 'Active' ELSE 'Inactive' END AS active_flag,

    C.name, C.company_code,

    SUM( CASE WHEN P.active_flag = 1 AND P.unregister_flag = 0 THEN 1...

  • RE: Sum and Count

    kapil_kk (4/17/2013)


    Nice question... learn something new today.. 🙂

    But can anyone plz explain me about the SUM part which is returning 12, I am not clear with this section :w00t:

    Change the...

  • RE: Substract End Dates

    Not sure but I hope this is what you need

    SELECTA1.*, COALESCE( A1.fg_eff_dt_key, 20790606 ) - COALESCE( A2.fg_eff_dt_key, 20790606 ) AS DiffDays

    FROMabc AS A1

    LEFT OUTER JOINabc AS A2 ON A1.fg_seq_nbr =...

  • RE: Logic creation

    kapil_kk (4/17/2013)


    Lowell (4/17/2013)


    well based on how i read your description, it sounds like a simple calcuated column could be used;

    ALTER TABLE [dbo].[GV_STNDetails]ADD STN AS RIGHT('0000' + CONVERT(VARCHAR,[From_StoreCode]),4) +RIGHT('000000' + CONVERT(VARCHAR,[STNID]),6)...

  • RE: Substract End Dates

    kiran.rajenimbalkar (4/17/2013)


    if end date column would be null then pls treat as 20790606

    please check only fg_end_dt_key column

    (20790606-20130416) ---660190

    (20130416-20130128) --288

    (20130128-20130128) --0

    This doesn't seem to be...

  • RE: Logic creation

    kapil_kk (4/17/2013)


    Please help me on this...

    The scenario that you have mentioned is not very clear.

    It would be good if you can explain your issue with some DDL and sample data...

  • RE: Substract End Dates

    kiran.rajenimbalkar (4/17/2013)


    not getting proper result Sir.

    I have tried.

    Can you also post the expected result based on your sample data?

    That will help people understand what you need exactly.

Viewing 15 posts - 301 through 315 (of 898 total)