Forum Replies Created

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

  • RE: is this involves a co-related subquery

    UPDATE [Table]

    SET flag = 1

    WHERE saNumber IN(SELECT saNumber FROM [Table] GROUP BY saNumber HAVING COUNT(*) > 1)

    Dave

  • RE: Insert into multiple rows, autonumber headache

    I Agree, I would firstly put the Max + 1 for each column into variables then use ROW_NUMBER() to assign the valid value.

    Dave

  • RE: Retrieving a nth highest row

    I think DENSE_RANK would be useful to you for your requirements, which will return records that have the same Salary, note I have also changed the order by to descending...

  • RE: Contrary of ISNULL() ?

    Same principal different code provided CONCAT_NULL_YIELDS_NULL is ON.

    SELECT ISNULL('Last Upload: ' + CONVERT(VARCHAR, AuthorDate+'', 112), '')

    FROM Documents

    Dave

  • RE: row_num/rank over date dimension table

    If i've understood your requirements correctly you might want to try DENSE_RANK()

    SELECT

    day_date,

    year_num,

    month_num,

    DENSE_RANK() OVER(ORDER BY year_num, month_num)

    FROM date_dim

    WHERE day_date BETWEEN '2009-11-01' AND '2010-01-31'

    Dave

  • RE: DateDiff Problem

    you could then use the SIGN() on the number of days, within a case statement. ie.

    CASE SIGN([Statement])

    WHEN -1 THEN 'Not till next year'

    WHEN 0 THEN 'Happy Birthday'

    ELSE CAST([Statement] AS VARCHAR)...

  • RE: Looking for a quick fix to data formatting problem

    Once the data is in the table I would change the columns data type to decimal provided the data in the column is decimal format:

    -- Check column in table contains...

  • RE: Comparing 2 Months

    The way I interpreted this thread was that what was needed was a count of new members that were not members the previous month. Have changed the MemberID's to smaller...

  • RE: select the most appearance

    SELECT TOP 1 WITH TIES Manufacturer, COUNT(*) FROM...

    Dave

  • RE: converting String to Number

    I don't understand why you are getting no results, the code below works for me...

    IF OBJECT_ID(N'Table1', 'U') Is Not Null DROP TABLE Table1

    IF OBJECT_ID(N'Table2', 'U') Is Not Null DROP TABLE...

  • RE: SQL w/ MAX function does not work

    Not 100% on this, but from what I understand (and after a few beers probably not alot!) this is what I've come up with...

    SELECT

    ...

    MaxFund.MaxDate

    ...

    FROM dbo.Fund F

    JOIN dbo.Fund_Valuation FV ON F.Fund_Number...

  • RE: problem selecting varchar

    This should work.. Spaces or not.

    SELECT

    SUBSTRING(LEFT(@A, 15), 0, LEN(LEFT(@A, 15)) - CHARINDEX(SPACE(1), REVERSE(LEFT(@A, 15))) + 1)

  • RE: Sum fields accross multiple days

    I used to come across this problem, the company I work for use 08:00- 07:59, if you subtract 9 hours from the Date (I subtract 8) you will get the...

  • RE: DISTINCT is not working with ROW_NUMER

    It's because the combination of fldCID and the ROW_NUMBER() are not distinct together, Try this...

    SELECT fldCID, ROW_NUMBER() OVER(ORDER BY fldCID) FROM (SELECT DISTINCT fldCID FROM @test-2) AS X

  • RE: need solution

    Presuming I understand you correctly, you need to get 1000 rows at a time - Have you Tried ROW_NUMBER()? You need something to order by though, and change the Between...

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