Forum Replies Created

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

  • RE: Using row results as dyamic columns?

    Here is the implemented example using PIVOT..

    /*Script to create Sample Data*/

    DECLARE @PercentData

    TABLE(Name VARCHAR(50),Department VARCHAR(10), Percentage float)

    INSERT INTO @PercentData(Name,department,Percentage)

    SELECT 'Gustav','GW',80 UNION ALL

    SELECT 'Gustav','NW',20 UNION ALL

    SELECT 'Olaf','D',100 UNION ALL

    SELECT 'Detlev','NW',50 UNION...

  • RE: Join/Union

    Dave Ballantyne (8/20/2009)


    setlan1983 (8/20/2009)

    Just in case where someone changed the entryt.EntryDateTime accidently, need show the record in exit table also.

    But WHICH exit row for WHICH entry row ?

    Presumably 'Bob' will...

  • RE: Join/Union

    Just visit the link below to go thru quick tutorial on sql outer joins

    http://www.quackit.com/sql/tutorial/sql_outer_join.cfm

  • RE: Join/Union

    In that case, you may use full outer join as follows:

    select

    ISNULL(entryt.EmpName,exitt.EmpName) EmpName,

    ISNULL(entryt.EntryDateTime,exitt.EntryDateTime) EntryDateTime,

    exitt.ExitDateTime

    from

    dbo.EntryTable entryt

    ...

  • RE: How to remove infinite loops in hierarchical data without using cursor?

    If I'm not wrong sample data may be like this...

    create table NodeItem

    (NodeID int, ParentNodeID int)

    go

    insert into NodeItem

    select 1 NodeID, null ParentNodeID union all

    select 11 , 1111 union all

    select...

  • RE: How to sort alphanumeric values

    Ok 🙂 Try out this..

    SELECT [ScheduleID],ScheduleName

    FROM [Schedule]

    ORDER BY CAST(CASE

    WHEN ScheduleName LIKE '%[0-9][0-9][0-9][0-9][0-9][0-9][0-9]' THEN RIGHT(ScheduleName ,7)

    WHEN ScheduleName LIKE '%[0-9][0-9][0-9][0-9][0-9][0-9]' THEN RIGHT(ScheduleName ,6)

    WHEN ScheduleName LIKE '%[0-9][0-9][0-9][0-9][0-9]' THEN RIGHT(ScheduleName ,5)

    WHEN...

  • RE: How to sort alphanumeric values

    Hope you're looking for this...

    SELECT {ColumnName}

    FROM {TableName}

    WHERE {ColumnName} LIKE 'Schedule%'

    ORDER BY CAST(REPLACE({ColumnName},'Schedule','') AS INT)

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