Forum Replies Created

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

  • RE: Retrieve data between 2 '.'

    How about this?

    SELECT *

    FROM #testenvironment

    WHERE PARSENAME(CAST(yourdata AS NVARCHAR(MAX)),3) IS NULL

  • RE: How to use GETDATE() function in sql server to select a column value from table whose date is only 1 year back from today.

    Select LTRating

    ,RHDate

    from Accounts

    WHERE LTRating <> 'D' OR RHDate = DATEADD(DD,-365,GETDATE())

  • RE: Days Difference Between 2 Dates

    Interesting stuff!

    Is there any specific reason when we do the following

    DECLARE @Date1 DATETIME SET @Date1= '2012-08-28 11:53:00'

    select CAST(cast(@Date1 AS float) AS DATETIME)

    That we lose 3 ms in the process of...

  • RE: SQL Server Query to group sequential dates

    Is the difference between the start date and end date of each row always fixed to be one day?

    Assuming it, something like this should do the trick:

    ;with sample_data AS

    (

    SELECT 769...

  • RE: TSQL Challenge 82 - Find elements that uniquely make up a group

    Would there ever actually be a business need for this? If so I think that some more fundamental questions need to be addressed!! 😀

  • RE: Fuzzy-String Search: Find misspelled information with T-SQL

    @ThomasKeller - I found the information from SimMetrics (linky) to be quite useful - what i think would be really interesting to see would be a weighted version of this...

  • RE: Fuzzy-String Search: Find misspelled information with T-SQL

    I've tended to find using a CLR implementation of the Jaro-Winkler algorithm has suited my needs a bit more, but really cool to see a T-SQL only alternative!

  • RE: Pivot Table Headache

    This doesn't use pivot but should do the job anyway:

    SET DATEFORMAT YMD

    ;WITH data as

    (

    SELECT 'Cat A' as category, '2011-10-01' as date,1 as response

    UNION ALL SELECT 'Cat A','2011-10-01',0

    UNION ALL SELECT 'Cat...

  • RE: Summarize Results from two tables, using one query.

    I think this should do the trick?

    SELECT

    table1.strlocation

    ,COUNT(table2.extension) as number_lines

    ,COUNT(table3.circuitTrunk) as number_trunks

    FROM tblUCSU table1

    INNER JOIN tblSCSU table2 on table2.adjPen2= table1.strPen

    INNER JOIN tblTACSU table3 on table3.adjPen2= table1.strPen

    GROUP BY table1.strlocation

    If there are records...

  • RE: Select Records Issue

    Would this work:

    SELECT name FROM company

    UNION ALL

    SELECT keywords FROM company

    UNION ALL

    SELECT area FROM landmark

    UNION ALL

    SELECT landmarkName FROM landmark

    Or does the ordering of the data within the one column differ from...

  • RE: Add one min when time same

    Gianluca has a strong point - I recently ran a similar query (with days), and by continually running through and adding another day onto duplicate cases, I was filling in...

  • RE: 95th percentile

    I think this should work for the specific month figures:

    ;with percentile as

    (

    select

    CAST(number AS DECIMAL(18,3)) as number

    ,month_name

    ,row_number() OVER (PARTITION BY month_name order by number asc) as row

    from #data

    )

    ,percentile2...

  • RE: 95th percentile

    You say that you want the median for each month - is this instead of the 95th percentile or on top (i.e. does the query need to calculate both simultaneously?)

  • RE: 95th percentile

    Try this:

    Based on the definition you gave, you can enter the percentile in the declare bit, or hard code it instead of the @percentile instead if you are always going...

  • RE: Unique sql request

    Sorry didn't spot it was a BIT! As Ninja's said, casting / converting to INT should do the trick

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