Forum Replies Created

Viewing 15 posts - 1 through 15 (of 17 total)

  • RE: A Pivot, but not exactly.

    the method above is useful since its dynamic, but i wanted to show you a more manual way of doing it as well.

    CREATE taBLE #TEMP

    (

    id INT,

    fk_id INT,

    ...

  • RE: Remove characters after last slash in string

    It bothered me now.

    So i had to come up with a way to, but I would prolly choose the first one opver my own.

    DECLARE @LastValue varchar(100)

    declare @string varchar (100)

    set...

  • RE: Remove characters after last slash in string

    Agreed, I am just being lazy :p

  • RE: Remove characters after last slash in string

    if you always know the len of the extnetion this should work as well without being so taxing.

    declare @string varchar (100)

    set @string = 'x:\folder1\folder2\folder3\test.txt'

    select SUBSTRING(@string,1, LEN(@string)-8)

  • RE: Remove Duplicates from a Table using specific columns

    if you're working on a huge amount of data I think the most optimized way would be to use the row)number function. This allows you to partition the values you...

  • RE: i want update the 2nd column based on first column:

    here you go broski!

    CREATE Table #TEMP

    (

    id varchar(100),

    MID VARCHAR(100)

    )

    INSERT INTO #TEMP

    VALUES ('100',NULL),

    ('200',NULL),

    ('300',NULL),

    ('400',NULL),

    ('500',NULL)

    UPDATE OP

    SET MID = OL.id

    FROM (SELECT LL.ROW_ID, LL.ID,LL.MID

    FROM(

    SELECT ROW_ID =ROW_NUMBER() OVER (order by ID),ID,MID

    FROM #TEMP I)LL)OP

    JOIN...

  • RE: Table Join using unique values or where Null = all values

    I think maybe you're looking for something like this?

    SELECT DISTINCT *

    FROM(

    SELECT * FROM #TableA

    where Area IS NULL )LL

    FULL OUTER JOIN #TableB CB ON LL.Area = cb.ColId

    LEFT OUTER...

  • RE: Help with the query!

    I must admit the guy who wrote the query qith the XML logic was an eye opener for me, I reallyed liked that method best. The way I have been...

  • RE: Obtaining Before & After Record & Missing Record.

    I would imagine your going to need to use the substring function as well as datepart function and possibly come CAST/COnvert functions in the mix. If you can supply a...

  • RE: Pivot Query with Count

    tsk tsk.

    I had some time after work to help ya out. Honestly the best way to go is dynamic sql. I gave you an explaination about piviot so you...

  • RE: Pivot Query with Count

    It can get a little tedious typing out all the months so I only did Jan,Feb,March and Dec. A dynamic pivot would be usefully if you are uncertain of the...

  • RE: import data from excel only from specific cells

    couldnt you copy the excel schema into a table form and sync up the rows and columns that way?

  • RE: how to remove null and minus symbol in PIVOT

    I think this is what you're looking for.

    Cheers.

    declare @col_Str varchar(max) ,

    @SQl_Query varchar(max);

    WITH substitue as (Select Distinct Reason from paymentHistory )

    --select @col_Str=isnull(@col_Str+',','')+reason from substitue;

    select @col_Str=isnull(@col_Str+'],[','')+Reason from substitue

    --select @col_Str=isnull(@col_Str+'],[','')+Reason from substitue

    select @col_Str='['+@col_Str+']'

    --select...

  • RE: Simple SQL Query

    Thats how I would have done it.

    Select TOP 1 COUNT

    FROM(

    select graph, sum(yesNo) as count

    from graph where dataName = 'data1' group by graph)J

    order by count desc

  • RE: Distributing the greatest value by rank in SQL

    Im a bit lost with the desired output. are you only comparing the first two rows? should the desired output in the 225 provided the industry and category are...

Viewing 15 posts - 1 through 15 (of 17 total)