Forum Replies Created

Viewing 15 posts - 7,801 through 7,815 (of 8,731 total)

  • RE: Query Help - Sum by Month

    After several tests, It became clear that Chris query is 1.5 times faster, at least on my development server. Although, both run in about one second for a million rows....

    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: Query Help - Sum by Month

    wolfkillj (8/7/2013)


    Sean Grebey (8/6/2013)


    Thanks for the replies. Out of curiosity, this is the approach I took. Is there an issue with it?

    select ROUND(sum(ContractValue),2) ContractValue, MONTH(ContractDate), YEAR(ContractDate)

    From Reporting.dbo.PrgSum

    Group by YEAR(ContractDate), MONTH(ContractDate)

    Only...

    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: Trying to select the last 3 months of data

    You could change it like this

    ;WITH base AS (

    SELECT Initial_Date = DATEADD( mm, -3, MAX(post_dm)) ,

    Final_Date = MAX(post_dm)

    FROM ztb_forecastable_metrics_hist

    )

    SELECT

    post_dm -- etc

    FROM ztb_forecastable_metrics_hist ztb

    JOIN base...

    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: Issue with Like Statement

    I see letter k in both rows.

    Kipling Road

    Alexandra Park

    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: Changing SQLServerCentral - Newsletter Layout

    The forums part is mainly useless for the purpose that is presented (Database Pros Who Need Your Help!) because most topics are already solved.

    There could be some kind of outstanding...

    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: Remembering that it is good to "get back to basics" every now and then

    Lowell (8/6/2013)


    no, you should say "Because @@rowcount is affected by any commands in the session, it's my practice to re-select from the table in case there was a trigger that...

    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: Query Help - Embed a \ string in a string

    First, I'm giving you the solution as you pictured it, but also another one that might be more effective. It's up to you to choose.

    set @sql = 'select (CAST(MONTH(ContractDate) as...

    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: Trying to select the last 3 months of data

    Why are you using a CTE when a normal query could work?

    If you give us more information on your query, we might suggest something different, but to solve your problem,...

    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: Multiple Rows with Multiple Columns into a Single Row

    If you only have 2 rows, then it can be easy to do it with MAX and MIN for your columns.

    SELECT id,

    MIN( Field1) Field1,

    ...

    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 with T-SQL to combine email addresses

    There's no need for a cursor or a while loop. Check the following article to solve your problem.

    http://www.sqlservercentral.com/articles/comma+separated+list/71700/

    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: Why do I have to sign in, each day, when clicking links from daily newsletter

    It's mostly a local issue, you're erasing the cookies or the history on your explorer.

    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: Date Parse Help

    You should avoid to use strings or integers to store dates. This might help you with your problem.

    SELECT CAST( STUFF(STUFF(STUFF(strDate, 13, 0, ':'), 11, 0, ':'), 9, 0, '...

    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: String Manipulation

    Something that's not LEFT( myString, CHARINDEX(' ', myString)) ?

    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: update records based on condition

    Here you go, it generates the expected output based on your sample data.

    ;With MySampleData([Member],[primarycondition],[primaryintensity],[secondarycondition],[secondaryintensity])

    AS

    (

    SELECT 'M2345','hf','1','','' UNION ALL

    SELECT 'M2345','COPD','1','','' UNION ALL

    SELECT 'M2345','CAD','1','','' UNION ALL

    SELECT 'M2345','dia','1','','' UNION ALL

    SELECT 'M2345','Ast','1','','' UNION ALL

    SELECT 'M2345','hf','2','',''...

    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: Right outer Join???

    The problem is that your WHERE clause is converting the OUTER JOIN into an INNER JOIN. Change those conditions to the ON clause and it should work as expected.

    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,801 through 7,815 (of 8,731 total)