Forum Replies Created

Viewing 15 posts - 5,326 through 5,340 (of 10,144 total)

  • RE: How to obtain Sum of count

    ;WITH SampleData AS (

    SELECT CId = 1, CCId = 'a', CCount = 3, totalCount = 6 UNION ALL

    SELECT 1, 'a', 3, 6 UNION ALL

    SELECT 1, 'b', 3, 6 UNION ALL

    SELECT...

  • RE: How to get latest Records based on Date column

    Can you write a SELECT which returns the rows you want to copy? If not, what's the date range which identifies rows to copy? This is trivial, is it homework?

  • RE: Monthly Aggregation

    You may find this modification easier to work with:

    SELECT

    x.MonthNo,

    x.[Year],

    x.[Month],

    COUNT(doclinkid) as Registered, -- is this correct?

    COUNT(DISTINCT doclinkid) as Registered, -- OR is this correct?

    SUM(x.Finalised) as Finalised,

    COUNT(*) -...

  • RE: Better Way to Perform this Query

    wolfkillj (1/15/2013)


    dwain.c (1/15/2013)


    wolfkillj (1/15/2013)


    I've been working on a set-based T-SQL solution to determine the Damerau-Levenshtein Distance between two strings. (DLD distance is just like LD - the number of changes...

  • RE: Better Way to Perform this Query

    Alan.B (1/14/2013)


    Jeff Moden (1/10/2013)


    Alan.B (1/10/2013)


    This morning before work for example, after a lot of effort, I finally figured out how to get the Levenshtein Edit Distance between 2 strings without...

  • RE: SQL Query

    pwalter83 (1/15/2013)


    ChrisM@Work (1/11/2013)


    Hi Paul

    I'll try to have a look over the weekend. Meantime, it's the last 5 mins of my last day here - and it's BEERTIME!

    Cheers

    ChrisM

    Hi Chris,

    I am still...

  • RE: How to join Values

    SELECT 'D' + LEFT(CAST(num AS VARCHAR(4))+'0000',4)

    FROM abc

    SELECT ISNULL('D' + LEFT(CAST(NULLIF(num,0) AS VARCHAR(4))+'0000',4),'0')

    FROM abc

  • RE: how top clause works

    sej2008 (1/15/2013)


    I found that TOP clause works little randomly with

    Select TOP 50 percent * from Tablename as it is not giving exact 50 percent in my result set .how it...

  • RE: SQL Query

    Hi Paul

    I'll try to have a look over the weekend. Meantime, it's the last 5 mins of my last day here - and it's BEERTIME!

    Cheers

    ChrisM

  • RE: SQL Query

    pwalter83 (1/11/2013)


    ChrisM@Work (1/11/2013)


    I think this better fits the spec:

    SELECT SUM(teu) AS TEU

    FROM NCV_BL ncv

    JOIN MG_VSLVOY_HEADER vh

    ON ncv.saisan_VESSEL_CD = vh.VESSEL_CD

    AND ncv.saisan_VOYAGE_CD = vh.VOYAGE_NUM

    AND ncv.saisan_LEG_CD = vh.LEG_CD

    JOIN MG_VSLVOY_PORT_CONTROL vpc

    ON...

  • RE: SQL Query

    I think this better fits the spec:

    SELECT SUM(teu) AS TEU

    FROM NCV_BL ncv

    JOIN MG_VSLVOY_HEADER vh

    ON ncv.saisan_VESSEL_CD = vh.VESSEL_CD

    AND ncv.saisan_VOYAGE_CD = vh.VOYAGE_NUM

    AND ncv.saisan_LEG_CD = vh.LEG_CD

    JOIN MG_VSLVOY_PORT_CONTROL vpc

    ON vh.VSLVOY_HEADER_ID =...

  • RE: SQL Query

    Why do you need to join to the other tables if they aren't contributing to the query, either as output or as a filter?

  • RE: SQL Query

    pwalter83 (1/11/2013)


    ChrisM@Work (1/11/2013)


    Paul, which table contains column 'teu'? (and 'BL_ID')

    Put that table first in the FROM list and inner join the other tables.

    Comment out all of the joins to...

  • RE: SQL Query

    Paul, which table contains column 'teu'? (and 'BL_ID')

    Put that table first in the FROM list and inner join the other tables.

    Comment out all of the joins to the other...

  • RE: Batch move/deletion of records

    Composable dml:

    INSERT INTO DataStaging_Archive (URN, DateProcessed, AnotherColumn, LastRemainingColumn)

    SELECT URN, DateProcessed, AnotherColumn, LastRemainingColumn

    FROM (

    DELETE TOP (@Batchsize) -- note: no order by, rows picked at random, see BOL

    FROM DataStaging ds

    ...

Viewing 15 posts - 5,326 through 5,340 (of 10,144 total)