15 minutes Interval from Hours - Please Help

  • zulfansari (2/20/2014)


    Now, not changing the requirements and trust me I tried to follow your last script but it's a little too much to digest right away, I know I will get it eventually, how would I change (if I have to) the 9 hours requirement to 3 hours?

    I did change the query from 9 to 3 but I know it's more than that 🙂

    That should be all you need to do. You just need to make sure you do it everywhere as it's in multiple places. It might be better to set it in a local variable and refer to that wherever you need to.


    My mantra: No loops! No CURSORs! No RBAR! Hoo-uh![/I]

    My thought question: Have you ever been told that your query runs too fast?

    My advice:
    INDEXing a poor-performing query is like putting sugar on cat food. Yeah, it probably tastes better but are you sure you want to eat it?
    The path of least resistance can be a slippery slope. Take care that fixing your fixes of fixes doesn't snowball and end up costing you more than fixing the root cause would have in the first place.

    Need to UNPIVOT? Why not CROSS APPLY VALUES instead?[/url]
    Since random numbers are too important to be left to chance, let's generate some![/url]
    Learn to understand recursive CTEs by example.[/url]
    [url url=http://www.sqlservercentral.com/articles/St

  • Woohoo, I just went from Grasshopper to a Rookie 🙂

    I did change the 9 to 3 and it's working beautifully 🙂

    How about if I want to see the 3 hours cap on daily basis?

    I mean based on the sample data we've been using, for the first day employee 1125 will have 3 hours of Double and 0 hour of Triple, then next day all 2.5 hours goes into Double, if he had 4 hours on third day then 3 hours of Double and 1 hour of Triple.

    This is not the main requirement but this could be needed for the next report, just thinking ahead.

    Thank you Dwaine..

  • zulfansari (2/20/2014)


    Woohoo, I just went from Grasshopper to a Rookie 🙂

    I did change the 9 to 3 and it's working beautifully 🙂

    How about if I want to see the 3 hours cap on daily basis?

    I mean based on the sample data we've been using, for the first day employee 1125 will have 3 hours of Double and 0 hour of Triple, then next day all 2.5 hours goes into Double, if he had 4 hours on third day then 3 hours of Double and 1 hour of Triple.

    This is not the main requirement but this could be needed for the next report, just thinking ahead.

    Thank you Dwaine..

    Z - When you are able to solve that requirement you get promoted from Rookie to Journeyman.

    Seriously, when that requirement does materialize, why don't you repost? After you play around and see if you can make it work of course (that's what would make you a Journeyman). I suspect it shouldn't be that hard if you take the time to decompose the various solutions I've provided you to see how each is working.


    My mantra: No loops! No CURSORs! No RBAR! Hoo-uh![/I]

    My thought question: Have you ever been told that your query runs too fast?

    My advice:
    INDEXing a poor-performing query is like putting sugar on cat food. Yeah, it probably tastes better but are you sure you want to eat it?
    The path of least resistance can be a slippery slope. Take care that fixing your fixes of fixes doesn't snowball and end up costing you more than fixing the root cause would have in the first place.

    Need to UNPIVOT? Why not CROSS APPLY VALUES instead?[/url]
    Since random numbers are too important to be left to chance, let's generate some![/url]
    Learn to understand recursive CTEs by example.[/url]
    [url url=http://www.sqlservercentral.com/articles/St

  • 🙂

    Sounds fair.

    I wish I can be as good as you someday however in the mean time I will keep on learning and try to decipher your codes to see if this is something I can resolve, if I do I will report back.

  • Well done Dwain!!

    Jason...AKA CirqueDeSQLeil
    _______________________________________________
    I have given a name to my pain...MCM SQL Server, MVP
    SQL RNNR
    Posting Performance Based Questions - Gail Shaw[/url]
    Learn Extended Events

  • SQLRNNR (2/20/2014)


    Well done Dwain!!

    Thanks! I worked pretty hard for that "Worked for the OP" stamp.

    What do you think of the new thought question in my signature links?


    My mantra: No loops! No CURSORs! No RBAR! Hoo-uh![/I]

    My thought question: Have you ever been told that your query runs too fast?

    My advice:
    INDEXing a poor-performing query is like putting sugar on cat food. Yeah, it probably tastes better but are you sure you want to eat it?
    The path of least resistance can be a slippery slope. Take care that fixing your fixes of fixes doesn't snowball and end up costing you more than fixing the root cause would have in the first place.

    Need to UNPIVOT? Why not CROSS APPLY VALUES instead?[/url]
    Since random numbers are too important to be left to chance, let's generate some![/url]
    Learn to understand recursive CTEs by example.[/url]
    [url url=http://www.sqlservercentral.com/articles/St

  • dwain.c (2/20/2014)


    SQLRNNR (2/20/2014)


    Well done Dwain!!

    What do you think of the new thought question in my signature links?

    Yes, I have been told that many times. They always want things to run slower since they charge by the ms.:-D

    Jason...AKA CirqueDeSQLeil
    _______________________________________________
    I have given a name to my pain...MCM SQL Server, MVP
    SQL RNNR
    Posting Performance Based Questions - Gail Shaw[/url]
    Learn Extended Events

  • SQLRNNR (2/20/2014)


    dwain.c (2/20/2014)


    SQLRNNR (2/20/2014)


    Well done Dwain!!

    What do you think of the new thought question in my signature links?

    Yes, I have been told that many times. They always want things to run slower since they charge by the ms.:-D

    Sheesh! And here I thought it was such an irony laden question I tweeted it this morning!


    My mantra: No loops! No CURSORs! No RBAR! Hoo-uh![/I]

    My thought question: Have you ever been told that your query runs too fast?

    My advice:
    INDEXing a poor-performing query is like putting sugar on cat food. Yeah, it probably tastes better but are you sure you want to eat it?
    The path of least resistance can be a slippery slope. Take care that fixing your fixes of fixes doesn't snowball and end up costing you more than fixing the root cause would have in the first place.

    Need to UNPIVOT? Why not CROSS APPLY VALUES instead?[/url]
    Since random numbers are too important to be left to chance, let's generate some![/url]
    Learn to understand recursive CTEs by example.[/url]
    [url url=http://www.sqlservercentral.com/articles/St

  • dwain.c (2/20/2014)


    SQLRNNR (2/20/2014)


    dwain.c (2/20/2014)


    SQLRNNR (2/20/2014)


    Well done Dwain!!

    What do you think of the new thought question in my signature links?

    Yes, I have been told that many times. They always want things to run slower since they charge by the ms.:-D

    Sheesh! And here I thought it was such an irony laden question I tweeted it this morning!

    That would be the life - raking in the $ by the ms for slow running queries.:cool:

    Jason...AKA CirqueDeSQLeil
    _______________________________________________
    I have given a name to my pain...MCM SQL Server, MVP
    SQL RNNR
    Posting Performance Based Questions - Gail Shaw[/url]
    Learn Extended Events

Viewing 9 posts - 46 through 53 (of 53 total)

You must be logged in to reply to this topic. Login to reply