Forum Replies Created

Viewing 15 posts - 7,846 through 7,860 (of 8,731 total)

  • RE: Sum the Attendance Hours by Category and then Group by 'Week of'

    Have you tried to use DATEPART(wk, Date)?

    What have you tried?

    Luis C.
    General Disclaimer:
    Are you seriously taking the advice and code from someone from the internet without testing it? Do you at least understand it? Or can it easily kill your server?

    How to post data/code on a forum to get the best help: Option 1 / Option 2
  • RE: How to write a codition based on min rank

    Here's a simple solution you could use

    select a.*,

    CASE WHEN a.RankID = MIN(a.RankID) OVER( PARTITION BY a.PatID)

    THEN b.ModelID /*ELSE 0*/ END ModelID

    from TableA1 A

    inner join TableB1 B...

    Luis C.
    General Disclaimer:
    Are you seriously taking the advice and code from someone from the internet without testing it? Do you at least understand it? Or can it easily kill your server?

    How to post data/code on a forum to get the best help: Option 1 / Option 2
  • RE: Getting DateOfBirth of youngest person.

    How about this?

    SELECT TOP 1 *

    FROM MyTable

    ORDER BY DateOfBirth DESC

    Luis C.
    General Disclaimer:
    Are you seriously taking the advice and code from someone from the internet without testing it? Do you at least understand it? Or can it easily kill your server?

    How to post data/code on a forum to get the best help: Option 1 / Option 2
  • RE: SQL dependency

    Eric M Russell (7/25/2013)


    In SSMS, you can right click an object and select 'View Dependencies'.

    As far as I know, those dependencies are only within the database. If there are objects...

    Luis C.
    General Disclaimer:
    Are you seriously taking the advice and code from someone from the internet without testing it? Do you at least understand it? Or can it easily kill your server?

    How to post data/code on a forum to get the best help: Option 1 / Option 2
  • RE: select distinct

    Without a lot of information, I guess you could do something like this.

    SELECT distinct BO.NMDOS,

    CASE WHEN FT.FNO = MIN(FT.FNO) OVER(PARTITION BY BO.NMDOS) THEN bo.ETOTALDEB END...

    Luis C.
    General Disclaimer:
    Are you seriously taking the advice and code from someone from the internet without testing it? Do you at least understand it? Or can it easily kill your server?

    How to post data/code on a forum to get the best help: Option 1 / Option 2
  • RE: Replacing important missing data by row

    I'm not sure you should do this as it might give you incorrect results if there are several people with same name and DOB (chances are low, but it could...

    Luis C.
    General Disclaimer:
    Are you seriously taking the advice and code from someone from the internet without testing it? Do you at least understand it? Or can it easily kill your server?

    How to post data/code on a forum to get the best help: Option 1 / Option 2
  • RE: Is it possible to return a value from a SP like this?

    Actually, there seems to be a problem with the median formula.

    This should perform better and give the correct results. It's up to you to change it to your needs.

    DECLARE @test-2TABLE(

    myintint)

    INSERT...

    Luis C.
    General Disclaimer:
    Are you seriously taking the advice and code from someone from the internet without testing it? Do you at least understand it? Or can it easily kill your server?

    How to post data/code on a forum to get the best help: Option 1 / Option 2
  • RE: Need help to build query

    Something like this?

    select *

    from sample

    WHERE a <> b

    OR a <> c

    OR a <> d

    OR b <> c

    OR b <> d

    OR c <> d

    Luis C.
    General Disclaimer:
    Are you seriously taking the advice and code from someone from the internet without testing it? Do you at least understand it? Or can it easily kill your server?

    How to post data/code on a forum to get the best help: Option 1 / Option 2
  • RE: basic sql question

    To avoid the zero and have nulls, you just need to eliminate the else.

    Luis C.
    General Disclaimer:
    Are you seriously taking the advice and code from someone from the internet without testing it? Do you at least understand it? Or can it easily kill your server?

    How to post data/code on a forum to get the best help: Option 1 / Option 2
  • RE: Indexing for Pivot Performance?

    Maybe this index will help

    CREATE NONCLUSTERED INDEX [IndexName] ON [dbo].[TableNAme]

    (

    [Id] ASC,

    [TradeDate] ASC

    )

    INCLUDE ( [Value]) WITH (SORT_IN_TEMPDB = OFF, IGNORE_DUP_KEY = OFF, DROP_EXISTING = OFF, ONLINE = OFF)

    But...

    Luis C.
    General Disclaimer:
    Are you seriously taking the advice and code from someone from the internet without testing it? Do you at least understand it? Or can it easily kill your server?

    How to post data/code on a forum to get the best help: Option 1 / Option 2
  • RE: basic sql question

    I'm glad I could help.

    Remember to try the pre-aggregation option to improve performance even more and you could check the second part of Cross tabs for further learning. You...

    Luis C.
    General Disclaimer:
    Are you seriously taking the advice and code from someone from the internet without testing it? Do you at least understand it? Or can it easily kill your server?

    How to post data/code on a forum to get the best help: Option 1 / Option 2
  • RE: code help where clause

    Sean Lange (7/24/2013)


    There really is no need for the ISNULL checks here.

    There's a need for a NULL validation since the OP wants to show NULLs as well.

    Luis C.
    General Disclaimer:
    Are you seriously taking the advice and code from someone from the internet without testing it? Do you at least understand it? Or can it easily kill your server?

    How to post data/code on a forum to get the best help: Option 1 / Option 2
  • RE: code help where clause

    I don't get it. Could you please post sample data and expected results? Check the article linked on my signature to guide you.

    Your description and the results seem to match,...

    Luis C.
    General Disclaimer:
    Are you seriously taking the advice and code from someone from the internet without testing it? Do you at least understand it? Or can it easily kill your server?

    How to post data/code on a forum to get the best help: Option 1 / Option 2
  • RE: Using DelimitedSplit8k against a Space Delimited Field - Problems

    You're welcome. I'm glad I could help 🙂

    Luis C.
    General Disclaimer:
    Are you seriously taking the advice and code from someone from the internet without testing it? Do you at least understand it? Or can it easily kill your server?

    How to post data/code on a forum to get the best help: Option 1 / Option 2
  • RE: basic sql question

    I believe this option is better for performance.

    SELECT ID,

    SUM( CASE WHEN Type = 'a' THEN Amount ELSE 0 END) AS Amount_A,

    ...

    Luis C.
    General Disclaimer:
    Are you seriously taking the advice and code from someone from the internet without testing it? Do you at least understand it? Or can it easily kill your server?

    How to post data/code on a forum to get the best help: Option 1 / Option 2

Viewing 15 posts - 7,846 through 7,860 (of 8,731 total)