Forum Replies Created

Viewing 15 posts - 6,676 through 6,690 (of 8,731 total)

  • RE: Dynamic Pivot table not grouping

    I'm not great at PIVOT, because I usually use CROSS TABS because they're more flexible to work with.

    Here's an example with your problem.

    To know more about dynamic CROSS TABS: http://www.sqlservercentral.com/articles/Crosstab/65048/

    To...

    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: rewrite cursor to set based

    I'll try to explain it.

    First, I'll create some sample data to follow along and keep it short.

    CREATE TABLE #SampleData(

    Criteria_Numberint,

    Criteria_Namevarchar(50),

    Calc_Pointsint,

    Max_Pointsint);

    INSERT #SampleData

    SELECT 1, 'Criteria A', 5, 10 UNION ALL

    SELECT 1, 'Criteria 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: Need help in Select case with tricky logic

    That seems to give the correct result. What's the problem? You could add an ELSE 0 to avoid having NULLs in your data.

    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 in Select case with tricky logic

    That's not difficult, 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: Finding previous even numbered month and appropriate year from given date

    I'm not sure what would happen with an even month, so I'm giving you 2 options.

    WITH Dates AS(

    SELECT CAST( '20140425' AS date) somedate UNION ALL

    SELECT CAST( '20140325' AS date) somedate...

    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: Are the posted questions getting worse?

    The Dixie Flatline (3/25/2014)


    My poster child interview disappointment: Good resume' on paper, but then the man walked in, opened up his laptop, and scrolled through a "cheat...

    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: rewrite cursor to set based

    Aditya,

    If you don't give an alias to the column, you don't need the nested REPLACEs. 😉

    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: Records for last 2 hours

    You will need to use DATEADD as well.

    http://technet.microsoft.com/en-us/library/ms186819.aspx

    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: rewrite cursor to set based

    I hope that you're ready for a great boost on performance. You didn't give any sample data, so there's a possibility that you won't get exactly what you're looking for...

    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: Finding Gaps in Dates

    Here's an option you could explore. The range used works for almost 7 days.

    The problem is that a gap between 2 Sessions can be covered by another one, so I...

    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 escape % when doing Like filter?

    That will return all countername values containing a percentage sign before the word, not only the ones that start with the percentage sign.

    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: Insert Blank row between result

    Why don't you try to get the solution?

    I can't give a great advice on the reporting tool, but you should look for grouping options and totals (group footers), for T-SQL...

    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 escape % when doing Like filter?

    Something like this?

    where countername like '[%]usage%'

    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: Calculating difference between two times with a twist (between 9am and 5pm)

    RedBirdOBX (3/25/2014)


    I was actually leaning towards a temp table....I will give it a try.

    Note that the temp table I used is to have the sample data. You don't need to...

    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: Calculating difference between two times with a twist (between 9am and 5pm)

    Maybe some brute force can help you.

    CREATE TABLE #Test(

    OpenTimetime,

    CloseTimetime)

    INSERT #Test

    SELECT '09:00:00', '17:00:00' UNION ALL

    SELECT '08:00:00', '18:00:00' UNION ALL

    SELECT '10:00:00', '20:00:00'

    SELECT *,

    DATEDIFF(MI, CASE WHEN OpenTime < '09:00:00' THEN '09:00:00'...

    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 - 6,676 through 6,690 (of 8,731 total)