Forum Replies Created

Viewing 15 posts - 961 through 975 (of 1,082 total)

  • RE: How to display 'datetime' as mm/dd/yyyy?

    Hi 🙂

    Here is what you are looking for:

    SELECT CONVERT (VARCHAR(13),@Vdt,103)

    Please remember that it 99% of the time a better option to format dates on the Client side with the...

  • RE: Display max value for all rows within group

    Hi Guys,

    How about trying this in 2000

    SELECT

    [1].Col1

    ,[1].Col2

    ,[1].Col3

    ,[1].Col4

    ,[Max]

    FROM dbo.Temp [1]

    INNER JOIN (SELECT Col1,Col2,Col3,MAX(Col4) as [MAX] FROM dbo.Temp GROUP BY Col1,Col2,Col3) [2]

    ON [1].[Col1] = [2].Col1

    AND [1].[Col2] = [2].Col2

    AND [1].[Col3] = [2].Col3

    Thanks

    Chris

  • RE: Display max value for all rows within group

    Hi,

    Yip that is only in 2005. Sorry what version is being used for this problem?

    Thanks

    Chris

  • RE: Shy Site Promoter

    Well done Steve that is Awesome stuff 🙂

  • RE: Display max value for all rows within group

    HI All,

    Have you tried using the OVER clause?

    Something like this should get you on your way.

    SELECT

    date

    ,store

    ,Trans_number

    ,prod_number

    ,random

    ,MAX(random ) OVER(PARTITION BY date ,store,Trans_number ) AS 'Max'

    FROM dbo.YourTable

    Thanks

    Chris

  • RE: Set-based Aggregates Problem

    HI MarkC ,

    that is perfect 10000% correct and so simple.

    Sorry I missed that. Didn't realise you could use partition and a order by in a over clause 🙂

    thanks again.

  • RE: Delimited list to Delimited Columns

    HI All,

    Here is another way to create a numbers table.

    Prob a good Idea to have a perm one in your db.

    SELECT TOP 100000

    ...

  • RE: Delimited list to Delimited Columns

    HI there

    Is this the kind of thing you looking for?

    --http://www.sqlteam.com/forums/topic.asp?TOPIC_ID=76033

    SET NOCOUNT ON

    DECLARE @VvcAgencyName VARCHAR(max)

    SELECT @VvcAgencyName = 'a b c d e f'

    CREATE TABLE #Numbers

    (

    [number] [int],

    CONSTRAINT [Index_Numbers] PRIMARY KEY CLUSTERED

    ([number] ASC)...

  • RE: Combining Rows

    I think it's pretty straight forward

    Table A

    Row1: ColA = 1

    Row2: ColA = 2

    Table B

    Row1: ColB = 1

    Row2: ColB = 2

    Row3: ColB = 3

    SELECT * FROM A INNER JOIN B ON...

  • RE: Paging Results in SQL

    That is correct.

    The user could click page 10 in which case we would need to show all the rows for that page.

    So I guess the correct question is.

    Would returning 700,000...

  • RE: "function"

    Hi,

    There are a few postings and articles for delimiting strings into tables.

    here is one that I saw the last time this someone brough this topic.

    hope it helps

    http://www.sqlteam.com/forums/topic.asp?TOPIC_ID=76033

  • RE: Selecting part of a String

    THis should do the trick:

    SELECT LEFT(NameCode, LEN(NameCode)-6)

  • RE: How to tell which is better?

    Sorry about that.

    Query one takes 66%

    Query two takes 34%

    thanks for the advice everyone

  • RE: It looks like it should be a Simple Select query... But its not!

    Hi,

    I'm a little confused.

    If you return the ID's then your count will be affect because of the group by.

    Unless what you looking to do is a partition?

    Could you give me...

  • RE: pivoting feature

    Hi,

    have you tried this:

    SELECT

    ID

    ,[2007-10-03] as [2007-10-03]

    ,[2007-10-04] as [2007-10-04]

    FROM

    (

    SELECT

    ID

    ,ID as [tmp]

    ,DATE

    ,[DATA]

    FROM MyTable

    ) p

    PIVOT(MAX([DATA])

    FOR DATE in ([2007-10-03],[2007-10-04])

    ) as pv

    thanks

    Chris

Viewing 15 posts - 961 through 975 (of 1,082 total)