CASE Question

I have a case statement that pulls days, hours and minutes from a number that represents total minutes:
CASE CAST(m.multi AS VARCHAR) WHEN '1' then CAST(m.elapsedtime/1440 as varchar(20)) +
':' + CAST(m.elapsedtime % 1440/60 as varchar(20)) +
':' + CAST ((m.elapsedtime %1440)%60 As varchar(20)) + ' (d:h:m)'
This does the job OK, but if the hours or minutes a re single digits it will return 4:6:8 (d:h:m) I need to use this format   4:06:08 (d:h:m)I tried using an IF:
IF( LEN(m.elapsedtime > 2, '0' + CAST(elapsedtime % 1440/60, CAST(elapsedtime % 1440/60, ) Varchar(20))
I thought you could use IF(True statement, option 1, option2) but I keep getting errors. Is this syntax valid inside a case statement?

You can use IIF starting with SQL Server 2012.
You can also use RIGHT( '0' + CAST(elapsedtime
% 1440/60 varchar(20)), 2)
Kalman Toth Database & OLAP Architect
SQL Server 2014 Design & Programming
New Book / Kindle: Exam 70-461 Bootcamp: Querying Microsoft SQL Server 2012

Similar Messages

  • North American Student Dashboard Challenge – Business Case Questions

    Students, post your business case questions for the North American Student Dashboard Challenge here.
    Good luck with the challenge!

    Two of the KPIs which need to be included in the dashboard are:
    1. Income vs Expenses
    2. Performance to Budget
    There is no income statement in the attached excel files, we are just given statement of cash flow. For individual items under revenue and expense we need an income statement. This is required for designing dashboard for KPI 1.
    For KPI 2, the case study asks to display comparison of Actual vs Budget for 4 revenue items - corporate, individual, foundations, and special events - as a chart component. The attached excel files does not have adequate information on this either.
    I see only two spreadsheets in the Excel file JA Financial Statements 2006 - 2011 - 1. Statements of Functional Expense; and 2. Statements of Cash Flow - Table.
    Please help what needs to be done here. The case study says to refer - Statement of Activites Tab from JA Financial Statements.xls for KPI 1 and KPI 2. However, there is no such spreadsheet on this Excel file. I have downloaded the project data from the following link: http://www.sdn.sap.com/irj/uac/index?rid=/library/uuid/30ee1571-2533-2f10-31bd-8826243425ee
    Thanks,
    Chandan

  • A Use Case question.

    Hello all
    I am currently developing an event management assignment for my degree.
    A subset of problem statment
    Attendee is a person, who would register with the application
    in order to view the posted events.
    For this part of the problem statment i have identified a usecase
    "register attendee".
    I will type the use case here. Since i am a novice, I would really like
    design gurus to throw some light on the use case and suggest me changes
    I will really appreciate it.
    Use case : register attendee
    Pre-condition: Attendee decides to register.
    Main Success Scenario:
         Actor                         System
    1. Attendee requests to register.
                        2. Provides registration form.
    3. Attendee fills the form and
    submits.                     
                        4. System checks for valid
                        authentication.
    (//for eg. unique username)
                        5. System validates the information
    (//for eg.compulsory fields
                             present or not)
                        6. System notifies through mail.
                        7. Displays registration was
                        successful.
    Alternative Flow :
    4 a) Invalid authentication : Displays appropriate message.
    5 a) Invalid information : Displays appropriate message.
    6 a) Mail notification failure : Logs the failure message and email.
    Please guide me friends. I am a bit confused.
    Thanks in advance.
    Jenny               

    Use case are pretty good for both of these. You know
    your system needs to allow an ATTENDEE to register
    with the SYSTEM using a REGISTRATION FORM. These sound
    like things that either you need to model (what
    attributes do the form and attendee have) or a thing
    that you need to build the "system".
    The steps in the use case tell you how the system must
    behave. It needs to "getRegistrationForm" and give it
    the attendee. The Attendee needs to
    "completeRegistrationForm" and
    "submitRegistrationForm". So, with the authentication
    and validation rounding out the process you have a
    good idea of what kind of methods you need as a base
    in order to deal with the real world concepts you have
    identified.I am through with what behaviour my system will need to provide in
    order to realize the use case. But I will have to assign the behaviour
    appropriately to classes of objects. I would like to go to the design model once i have a good understanding of the domain model. This is where the problem starts, should i identify, AuthenticationVerifier,InformationVerfier as different concepts and give later say AuthenticationVerifier the responsibility of verifying unique authentication and InformationVerfier the responsibility of verifying information received with the form or should I only take one concept of say Administrator that would perform the above two stated behaviours. I understand that it is always good to overspecify concepts rather than under specify but at some point of time i will have to make that decision.
    If its a libray system, it is easy to identify certain priliminary concepts say book, patron, etc. as they occupy some physical space. But here nothing is clear. There isn't any entity in my use case, that occupies a physical space that i can easily identify as a real world concept.
    My question is, how in this case, do someone define the notion of concept when there is nothing in the main success scenario that occupies space. My use case, only specifies what will be done with the
    attendee information, not who will do it. So as a use case developer, am i responsible to map these processes with some physical entities that i have derived for eg. AuthenticationVerfier.
    ps. You will need to add the Attendee as an Actor. She
    is the one that is initiating the activity.Does it mean that as Attendee is an actor, he/she cannot be a concept?

  • Case Questions - Size and Drive Mounting

    Planning ahead for a new i7 system, I'm going to buy components as I find them on sale... so have 2 questions about a new case
    First is Drive Mounting
    Everything I see today (have not looked at every possible case) uses some kind of "thumb lock" to mound 5.25 drives, such as a DVD drive or, in my case, the hard drive swap hardware I am going to use (Vantec MRK-200ST-BKSATA which goes in a 5.25 opening, then hard drive goes in a housing to slide in and out easily)
    I am used to the old style case with screw holes to mount 5.25 drives... so... do the new style cases really work well to hold a drive securely?
    Next question is about case size
    I'm looking at a mid-tower case http://www.newegg.com/Product/Product.aspx?Item=N82E16811119196 that seems as though it is plenty big enough for my needs, with enough 5.25 openings for DVD and two hard drives... and 3 case fans for cooling... and what looks like plenty of case width to be able to put a Noctua cooling tower on the i7 CPU
    I'm also looking a  full-tower http://www.newegg.com/Product/Product.aspx?Item=N82E16811119160 that doesn't seem to me to "really" offer anything more I need, since I'm not going to have a raid array and will only have 1 video card
    But... is there some advantage I'm not seeing to having a full-vs-mid-tower case?

    I did what I should have done in the 1st place, and read the size specifications
    A full tower case won't fit in my cabinet (heavy wood furniture we... ie the designer wife... bought for both sides of the office)
    I don't need as many external drive bays as the F-T has, so the mid-tower will do fine on that specification
    The Coolermaster Scout comes with 3 fans... front, top and back... and has side mounting for up to 2 more for CPU and video card... so I don't think cooling will be a problem
    Now, my only point of "wonder" is never having used the type of drive mounting it has... some sort of "thumb thing" you push to lock?
    But, since ALL the cases I've looked at seem to have the same/similar mounting, I guess they work OK
    Since the CM Scout, and the Corsair 850w power supply are both on sale right now, I think I'm going to buy when I get done with the Honey-Do list and put them away until I'm ready to build... which will be when Win7 64bit is a SP-1 level
    Thanks for the comments
    ADDED
    Found some pictures of the CM Scout, one of which was of the "stuff" that comes with the case
    There are drive "rails" included that look like they go on the sides of the 5.25 drives, and then those are locked into place by the quick release case locks
    ADDED2
    I have been planning on using drive swap hardware (like my current computer) to easily change boot or data drives... but now I'm thinking I'll just keep an extra drive on hand, with an Image of the boot drive made to external drive, and only actually change a drive in case of failure
    I now use a dual boot with 1st boot Win2k and Premiere 6 to run my Pinnacle Dv500 and 2nd boot WinXp, so will just set up one drive with Win2k and Win7 64bit
    I'll most likely get a 320Gig Sata drive for boot (and extra in reserve) and a 1-T Sata drive for data... with 1-T of space, I can simply put different projects in different folders and, for SD work, I'll have ample space (and, by the time I actually build, I may be able to afford a 2-T data drive)
    ADDED3
    While they are on sale, and to spread the hit to my tiny budget, I ordered PS and Case today
    PS - http://www.newegg.com/Product/Product.aspx?Item=N82E16817139009
    Case - http://www.newegg.com/Product/Product.aspx?Item=N82E16811119196
    Next month (or sometime soon) I'll watch for Sata drives on sale at Newegg
    I'm going to wait until just before I build to buy a motherboard, since by then the Gigabyte I'm looking at MAY be on a 2nd revision with refinements

  • Stupid case question...

    You folks have scared the crap out of me with all the cracked screen problems.
    I have crafted a hard shell case for my white nano made out of a small eyeglasses case with a whole cut out for the headphone jack. I also added some soft foam so it doesn't jostle around.
    One question though, can the nano overheat and be damaged this way?

    Probably not. My other iPods have been kept in cases without apparent harm - and my oldest iPod will soon by four years old. The only time the iPod heats up is when it is recharging so if you have any concerns about overheating, you can take it out of the case when charging it.

  • H8-1520T Case question and OS transfer question

    Hello all in the forums here.
    My first question is this- I have an HP H8-1520T and noticed on the back next to the main system fan there are what look like metal shields that you can take out. I was wondering if this is what they truly are, and if so what the purpose would be. I noticed it was located close to the pump fan pins on the motherboard, so I can only assume it would be to allow for a radiator if one wanted to water cool their system. If this is the case, what size and thickness radiator would fit, because I want to water cool my system but don't want to have to buy a new case if I dont have to.
    My second question is this- I recently bought a SanDisk Ultra II SSD for my boot drive. I was wondering how to transfer the OS from my 1TB Seagate Barracuda to the SSD. I have already tried two programs, Paragon's Migrate OS to SSD 4.0 and Seagate's DiscWizard software, both to no prevail. I was wondering how to transfer it.
    Thanks

    There are many SSD Migration Guides, provided by the SSD manufacturers as well as computer industry magazines.
    For "Cloning" your new Solid State Drive (SSD), SanDisk recommends
    Apricorn® EZ Gig IV with Data Select.
    http://mp3support.sandisk.com/downloads/um/ssd-install-guide.pdf
    The SanDisk SSD Conversion Kit comes with Apricorn® EZ Gig IV with Data Select for convenient data-migration, which copies files from your existing hard drive to your new SSD.
    http://www.sandisk.com/products/ssd/sata/conversion-kit/
    Macrium Reflect is a free migration tool (clone hard drive), used by some SSD installers.
    http://www.maximumpc.com/how_clone_hard_drive_or_ssd_2014
    Click on the green Download Now button (Cnet.com repository) for Macrium Reflect
    http://download.cnet.com/Macrium-Reflect-Free/3000-2242_4-10845728.html?part=dl-&subj=dl&tag...
    Samsung uses a Proprietary Migration Product, specific for their SSD products.

  • Quick Case Question...the other case thread di

    I am looking into this silicon case:
    http://www.capdase.com/pic/product/538_s.JPG
    ^^^ decent included screen cover!
    My main question is: can a silicon (or leather!) case protect the Zen Micro from a fall? Is silicon in general a poor choice for a case? Any input would be appreciated. Thank you.

    Nothing can guarantee your player will survi've a fall.

  • IPod "Repair" and case question

    ok so i sent in my 30 gb iPod 5g for service and they recieved it yesterday (jan 26), the click wheel was slightly off its place, and the center button was loose.. i guess. How long do you think it will take to get back? Do you think they will replace it, or will they jst fix and return??
    and in the mean time i need to buy a new case for it. What cases do you all like? i had a Kickstand one but it scratched the **** outa it, and it was hard to use the clickwheel... and i got a silicone and it wasntexactly comfy and would slip and feel wierd in my pocket. i think it was just a ****** case. Does anyone know a real good case? i want it to be easy to use preferably a glass casse or sumthin i can easily squeeze into my jeans pocket and it wont get all nasty... thanks

    Welcome to Apple Discussions!
    See this...
    http://www.apple.com/support/ipod/service/faq/
    It should take about a week.
    btabz

  • IPhone case question

    A friend of mine has a different company's phone which tilts up on it's base (landscape mode) so that he can watch Slingbox while the phone sits on a table.
    I enjoy taking my iPhone on airplanes with movies on it to watch. Holding it in a position to see it for hours, however, has my arm cramping eventually.
    Does anyone know of an iPhone (original iPhone) case which has a tilt mechanism so that you could set the phone on the tray top and watch it without holding it? If not, someone should develop and sell it.

    There are some like that. Usually the tilt is handled by a belt clip which rotates to become a tilt bracket. If you go to iLounge
    http://www.ilounge.com/index.php/accessories/
    and scroll to iPhone cases you can find descriptions for a wide selection of cases with descriptions. Some mention the feature you want.
    Phil

  • Case Question -- iSkin Solo FX Mirrored Screen Protector

    I'm considering the iSkin solo FX case for my new iPhone (http://www.iskin.com/solo/). It comes with a mirrored screen protector. I'm assuming the mirrored faceplate is like a two-way mirror, allowing light to emit from behind. Anybody tried this case? Does the mirrored face cut down on the brightness of the iPhone's screen?

    The case is real cool ( i have the burnt orange one.) Real sleek, and grips nicely on hard surfaces. 2 BUTS: the mirror face always looks grimy, because it shows every single fingerprint, (especially if you have lotion on your hand or face.) And some dirt accumulates along the side edges. But the look is nice (definitely a two-way mirror effect) and only cuts down on the brightness of the screen about 5%.

  • Change profit center case question

    Hi there:
    Here is my scenario: Let's say material A has wrong profit center assigned in plant 0001 as PC0001, but the correct profit center of it should be PC0002 and it had inventory in plant 0001, how do we execute profit center change for above case? Before changing it to correct profit center in material master, do we need to do anything else?

    Hello,
    1. IF there is existing stock for any of these material then system will not allow to change in MM02 since the stock value is taken in FI. It will through error. you can change the message type to u201CWu201D instead of u201CEu201D  using Tcode u2013 OMT4 if you want after checking with business 
    2. Impact will be in the stock inventory value taken last month will be in profit center ABC and if we are changing this month then it will be CDE
    3.The best way is
    To issue all stock first to a cost center with 201 movement, then change the profit center, then get the material back with 202 movement.
    There are lot of SDN's on this topic can xplore more
    Hope this helps
    PBB

  • HELP - Nested Case Question (Multiple Rows)

    OK, Now that the syntax has been corrected with the help of "Chanchal Wankhade" (Thank you very much!), I have an entirely new issue. I am sure this issue has to do with my case statement logic. I am getting multiple rows, when I am only looking for one. Here is my code:
    SELECT
      CASE
        WHEN EP.PHYSICAL_DATE IS NULL
        THEN
          CASE
            WHEN EC.ORIGINAL_CONTRACT_START < ((SYSDATE) - 365)
            THEN 'NEEDS PHYSICAL'
            WHEN EC.ORIGINAL_CONTRACT_START < ((SYSDATE) - 330)
            THEN 'COMING UP'
            ELSE 'No'
            END
        WHEN EP.PHYSICAL_DATE IS NOT NULL
        THEN
          CASE
            WHEN MAX(EP.PHYSICAL_DATE) KEEP (DENSE_RANK LAST ORDER BY EP.PHYSICAL_DATE) < ((SYSDATE) - 365)
            THEN 'NEEDS PHYSICAL'
            WHEN MAX(EP.PHYSICAL_DATE) KEEP (DENSE_RANK LAST ORDER BY EP.PHYSICAL_DATE) < ((SYSDATE) - 330)
            THEN 'COMING UP'
            ELSE 'No'
            END
      END "Needs Physical?"
    FROM AP AE
    LEFT JOIN EMP_PHYSICAL EP
    ON AE.EMP_ID = EP.EMP_ID
    LEFT JOIN POSITION_OFFERED PO
    ON AE.EMP_ID = PO.EMP_ID
    LEFT JOIN EMP_CONTRACT EC
    ON AE.EMP_ID         = EC.EMP_ID
    WHERE PO.ACTUAL_END IS NULL
    AND (EP.PHYSICAL     = 1
    OR EP.PHYSICAL      IS NULL)
    AND :P71_EMP_ID = AE.EMP_ID
    GROUP BY EP.PHYSICAL_DATE, EC.ORIGINAL_CONTRACT_START;The OUTPUT is:
    Needs Physical?
    Row 1 NEEDS PHYSICAL
    Row 2 No
    However, only one of these rows should be the output, which is "No". How do you get a nested case statement to evaluate to one result, instead of multiple? I'm quite sure it is in the logic. To spell it out, this is what I am trying to accomplish with the above code:
    If the "EP.PHYSICAL_DATE" is null, then use these sets of formula's to evalute the output, BUT if the "EP.PHYSICAL_DATE" is not null, then use these set's of formula's to evaluate the output.
    As it stands now, it appears as if my nested case statement is doing exactly what I told it to do, which is to evaluate both conditions, and output both.
    Any help would be appreciated. Thanks.
    Aqua
    Edited by: AquaNX4 on Mar 26, 2013 6:30 AM

    If you define your service_level as a table then it will be much easier.
    with service_level
    as
    select 'ALL' parent_lvl, 'Sergeant' srv_lvl from dual union all
    select 'ALL', 'Bonus I' from dual union all
    select 'ALL', 'Deputy Bailiff' from dual union all
    select 'ALL', 'Deputy Lockup' from dual union all
    select 'ALL', 'Deputy Bailiff Security' from dual union all
    select 'ALL', 'Custody Assistant' from dual union all
    select 'ALL', 'Security Officer' from dual union all
    select 'ALL', 'Security Assistant' from dual union all
    select 'ALL', 'Security Officer and Security Assistant' from dual union all
    select 'ALL', 'Private Security' from dual union all
    select 'All Deputies', 'Deputy Bailiff' srv_lvl from dual union all
    select 'All Deputies', 'Deputy Bailiff Security' from dual union all
    select 'All Deputies', 'Deputy Lockup' from dual union all
    select 'All Sworn', 'Sergeant' srv_lvl from dual union all
    select 'All Sworn','Bonus I' from dual union all
    select 'All Sworn','All Deputies' from dual union all
    select 'All Sworn','Deputy Bailiff' from dual union all
    select 'All Sworn','Deputy Lockup' from dual union all
    select 'All Sworn','Deputy Bailiff Security' from dual
    select *
      from in_service
    where rank IN (
              select srv_lvl
                from service_level
               where upper(parent_lvl) = upper(:SL)
                  or upper(srv_lvl) = upper(:SL)
                   )

  • 2008 MacBook pro Case Question

    Hello all,
    I rececntly bought a late 2008 MacBook pro Pre Unibody model.. I love it.. it's by far the best laptop I've ever used or owned..
    Anyway
    I like it so much, I am looking for a case for it, I cant seem to find any on Amazon though.. I know it's a slightly older model but..
    Anyone Have any Ideas about where to find one?
    Thanks
    Cap10323

    Cap10323,
    does a search for “17 inch macbook pro case” on Amazon return no products at all?

  • Old MacBook Protective Case Question

    I have an older White MacBook (before 2009). I bought it in the summer of 2008. I'm trying to shop for a protective case for it as the one I originally bought has broken. I've tried searching around online and haven't been able to find anything. I just keep coming across the Unibody model. I'm just wondering if there's someone out there who knows where I can find a case, particularly the incase brand.
    Thank you.
    Kristen

    This ebay site apparently sells hard cases (absolutely NOT Incase or Speck brand) for 2006-early 2008 MacBooks, shipped from Hong Kong. I haven't purchased one from this vendor so I can't vouch for them.
    http://www.ebay.com/itm/Crystal-Hard-Case-Cover-for-OLD-Macbook-White-13-A1181-w ith-keyboard-cover-inch-/251321943334

  • Case Question - Inivisible Shield?

    I was curious as to peoples response to the Invisible Shield brand protection for iPods. I just heard of it, and am a little skeptical...
    What is the condition of the iPod after you remove the product?
    Do the edges of the "shield" really stay stuck, or do the peel up and look funky and dirty?
    Or if anyone has any other recommendation for a similar, full body protector.
    (I like something that would allow the actual iPod to be shown. I don't like the leather and hard shell cases much...)

    I just took one off of my 5G iPod after about a year because it was finally starting to show some wear and tear. The iPod itself looked like as if had it just came out of the box after the film was removed. No residue etc.
    I can't imagine any scenario of how your iPod could look dirty and scratched up after removing it unless you failed to follow the instructions to clean it thoroughly before applying the material.
    I use them on my cellphone, camera LCD's etc. Been very happy with them.
    Here is another opinion that makes the same "scratch free" claims.
    http://gadgets.fosfor.se/invisible-shield-review/
    And a review after 1 year of use/abuse
    http://www.rainydaymagazine.com/RDM2006/GearNGadgets/September2006/InvisibleShie ld/RDMGG_InvisibleShiedITW.htm

Maybe you are looking for