Using more than one case when statement

Hi there,
I have a question on using case when statements.
Currently I have a table where it shows me mulitple dates.
Order Saledate TransferDate StartDate Enddate GetDate
I have created a where statement to show me records against the transferdate dependant if it appears within the date range of the year, or if it appears within the startdate and today's date.
(lpatran.trandate between targets.startdate
and (case when targets.enddate < getdate() then targets.enddate else getdate() end))
However on some of the records the transfer date is null, and so they want to use the saledate as the date to use.
So I created
(case when Lpatran.trandate is not null then (Lpatran.trandate between targets.startdate
and (case when targets.enddate < getdate() then targets.enddate else getdate()))
else (lpatran.saledate between targets.startdate
and (case when targets.enddate < getdate() then targets.enddate else getdate())) end )
However it gives me an incorrect syntax near the word ‘between ‘ 
Is there a simple fix for this or does sql not allow me to do this?

I have created a new column called transferdate and done a case when statement
CASE
WHEN lpatran.trandate
IS
NULL
THEN lpatran.saledate
ELSE lpatran.trandate
END
AS Transferdate,
Then created a temptable and did a select * from temptable.  Created a where statement from transferdate, which does work and gives me the correct data. 
TransferDate between startdate
and(case
when enddate
<
getdate()
then enddate
else
getdate()
end))
However I wanted to know if there was a way of obtaining the same data without having to use the temptable ?

Similar Messages

  • Can I use more than one transition when creating a slideshow in IDVD

    I want to use more than one transition in IDVD when creating a slideshow, is this possible?

    Not so. Under Windows select Photos.
    That will show the Media Browser in the lower right hand corner of iMovie.
    Use the File ➙ New Project to create a new project.  Select the photos from iPhoto you want to create a movie from and drag into the new project area.
    From there add your transitions, music, etc.

  • I use more than one computer to access my four business email accounts. When one computer is on (and mail is open) emails do not get through to the other computers. This is fine, but how do I make one of the other computers the dominant one?

    I use more than one computer to access my four business email accounts. When one computer is on (and mail is open) emails do not get through to the other computers. This is fine, but how do I make one of the other computers the dominant one?

    I assume these are POP accounts and all computers are set to remove from Server after downloading.
    So on the non dominant ones... Mail Preferences>Accounts, highlight an account, Advanced tab, uncheck remove from Server, just have the main dominant one remove from server.
    Or get/setup IMAP accounts.

  • I have just started using WD external hard drives, I use it to save my movies and music on. On more than one occasion, when I connect to my MacBook it erases everything on had on there. Can someone please help with this problem?

    I have just started using WD external hard drives, I use it to save my movies and music on. On more than one occasion, when I connect it to my MacBook it erases everything I had save on the hard drive. Can someone please help me with this problem? I am super tired of having to put all of my movies and music on the hard drive just to have it erased again. The products I am using are WD 4TB My Book and 2 TB My Passport external hard drives. When it happens, there is always an icon that reads, EFI, along with the My Book icon. Thank you for your assisstance.

    dwgar1322 wrote:
    I have just started using WD external hard drives, I use it to save my movies and music on. On more than one occasion, when I connect it to my MacBook it erases everything I had save on the hard drive. Can someone please help me with this problem? I am super tired of having to put all of my movies and music on the hard drive just to have it erased again. The products I am using are WD 4TB My Book and 2 TB My Passport external hard drives. When it happens, there is always an icon that reads, EFI, along with the My Book icon. Thank you for your assisstance.
    Yes, you have WD software installed  REMOVE IT !! 
    WD has warned its customers about their huge mistake that their software doesnt work on Mavericks and causes data loss.
    (also dont use WD drives anymore)
    Read all about it here:
    https://discussions.apple.com/thread/5475136?start=255&tstart=0
    See their website on removing the destructive WD software here:
    http://community.wd.com/t5/External-Drives-for-Mac/External-Drives-for-Mac-Exper iencing-Data-Loss-with-Maverick-OS/td-p/613775
    Western Digital External Hard Drives Experiencing Data Loss On OS X Mavericks
    http://www.cultofmac.com/252826/western-digital-external-hard-drives-experiencin g-data-loss-on-os-x-mavericks/

  • When using more than one tab, once I have opened a pdf using firefox my laptop will not allow me to type or click in another tab unless I drag the pdf into it's own window?

    when using more than one tab, once I have opened a .pdf using firefox my laptop will not allow me to type or click in another tab unless I drag the .pdf into it's own window? not a major problem just irritating.

    I found the cause but no solution, it's actually a plugin that does that: divx plus weblpayer (it gets installed when you install DivX on your system), if you disable it and restart firefox it all works again. But I want that plugin... so DivX need to fix this, unless it is a Firefox bug in its own core... anyway these two together creates the problem.
    (I'm running Firefox 9.x on OSX Lion)
    I also wish firefox tab tear out tab worked more like chrome's tab tear out, much friendlier...

  • Use more than one song on slideshow?

    When it comes to both Final Cut Pro HD vs. Final Cut Express HD...
    With either one can you use more than one iTune song when making a picture slideshow? I currently just use iMovie to do this but with iMovie I can only use one song.
    Considering upgrading but want this option.
    Thanks!

    Oops actually I meant iDVD ipo iMovie. But yes, it is a standard feature for music under Media in iDVD.
    Does anyone know why you couldn't use your music from iTunes when making a movie in FCP? In my case they are home movies and I am just looking to jazz them up a little.

  • Can you use more than one email address on one account as to enable two or three devices to use imsg????

    Can you use more than one email address on one account as to enable two or three devices to use imsg as when i add new email address's in settings it just says veriyfying and nothing happens????

    If I read your question right, yes.
    My pad has two e mail addresses, and my phone has a phone number as well as a e mail address.  For each device you can add additional 'receive at' addresses in settings.
    Note, when you add a new address, apple will send an e mail to that new address that you need to respond to, to show that it is a valid address.  So look in the inbox of that e mail account for the verification e mail.  Note further, some spam filters think that the verification e mail might be spam, so if it does not show up in your in box, look in any spam file you might have.
    in my case, the verification e mail came within a few minutes of declaring the new address.
    The multiple address are useful if you have more than one device under your apple id, and want to be able to send stuff to that particular device.

  • Can't use more than one computer

    It appears to be impossible to use more than one computer with the shuffle.
    Connecting to another computer results in choosing between erasing the library and linking to the second computer's library or not mounting the iPod.
    I did not expect this behavior and it is very deceptive.
    Tech support seems unable to figure it out. If it can't do it then the techs should say so and the literature should so indicate it
    Very unlike what I expect from Apple

    Apple cannot aid in the ability to load entire music
    libraries from different computers onto one pod as it
    would be prone to copyright infringement abuse. That
    is why what you are requesting to be done is not
    automatic through iTunes.
    I understand that. My daughter downloaded purchased music using her sister's computer and the gift card from her sister whom she was visiting on their shared birthdays .
    I agree that tech support should just told you
    directly what you wanted to know but you are equally
    at fault for assuming this ability ever existed
    without doing 5 minutes of research.
    A simple google of the terms would have yielded the
    answer you wanted.
    When she got home she wanted some help putting some more music on her shuffle (a gift from us) from a cd of a friend's local band to use during her last chemo treatment the next day. Her Mac is running 8.6 so she asked me to do it for her.
    I dragged the files and dropped them on the ipod icon for her thinking that would be the simple Apple way.
    Couldn't play them, though I could see them. Couldn't see the purchased music (when double clicking the icon) but could hear the music. That started the search.
    I do appreciate the copyright issue but Apple tech should have known the answer right away, not after the fourth tech contact. No where does it state simply that one cannot do this and I don't agree that I am at fault to assume that I could.
    Subject closed.
    TiBook 15 1 gHz    

  • How can I use more than one Data Provider in my web Apps

    I am trying to use two different data provider in my web apps to run two different queries from the same table ,the data provider A is working correctly but when I attempt to run data provider B ,It display an error page ,here is the error message : Exception Details :javax.servlet.ServletEx ception
    java.lang.RuntimeException: java.sql.SQLException : Cannot connect .Both dataSourceName and url properties are null.

    Hi,
    You can use more than one data provider in your application. However if you have defined a dataprovider for a particular table already, and wish to bind a component, select the component and use its context menu to Bind to Data...

  • Can I use more than one Apple ID on one device

    I have seen some answers to this type of question before but not that since the ios 6 so will ask again. My household shares an Apple ID and it has worked great as we have added devices and purchased apps.  My problem now is this, we have hit a point where I have work things on my iPad and iPhone that I really don't need to be shared with the whole family but it isn't a major deal or security risk. I don't want to give up the advantages of having the household ID.  Is there an easy way to have another ID on my iPad and switch between them without having major complications?  I am for the most part a techie so not afraid of these kind of things but I can't afford to lose everything right now and take the time to set it all back up so getting advice here.  Thanks in advance for any help you can give.

    You can use more than one apple id, but keep in mind that when apps need updating that you'll will need to sign in with correct credentials to update them.
    Share an apple id for the itunes and app stores, but keep your own for icloud, facetime and messages.
    Managing and Sharing multiple id's with your family
    http://www.macstories.net/stories/ios-5-icloud-tips-sharing-an-apple-id-with-you r-family/

  • Can u use more than one apple account on your device and itunes

    Can u use more than one apple account on your device and itunes

    Yes, but you have to logout of one, and login to the other.
    If it is an iPhone/iPad/iPod Touch and you buy apps on different accounts, when it comes time to update an app, you have to specify the password for the account used to acquirer the app. You change an iOS account via Settings -> Store -> Apple ID (tap on it), and start by logging out and then you can enter the other Id
    So it is possible, but it can also be a pain.

  • Can I use more than one bluetooth device at a time with my iphone4

    Can I use more than one bluetooth device at a time with my iphone4

    Anthony
    I have a Plantronics 975 earpiece that works very well with my Razr.  I
    just got a Panasonic KX-TG7873S phone system for my home, it has a
    "Link-to-Cell" cellular convergence solution, from what I understand it is
    just Bluetooth enabled.  I have paired both device with my Razr.  In
    settings, Bluetooth setting, both device show.  But only one device can
    connect at a time.  If my Plantronics is connected and I choose the
    Panasonic device, the Plantronics device disconnects and the Panasonic
    device then says it is connected.  Both devices work when they
    are connected.  Is it because they are both "headsets"?
    So, to have to remember to connect to one or the other device, depending on
    weather I am coming or going is not practical.
    On Sat, Sep 14, 2013 at 1:14 PM, Verizon Wireless Customer Support <

  • Using more than one PU and PC for the same database

    I have a scenario described here: [http://www.seamframework.org/Community/UsingTwoParallelNestedConversationsWithParentAtomicConversation|http://www.seamframework.org/Community/UsingTwoParallelNestedConversationsWithParentAtomicConversation]
    which uses Seam, EJB3, JPA, Hibernate, Richfaces (modalPanel) and JSF.
    The question I have is the following:
    is there any negative consequence (memory consumption, performance hit, etc.) of using more than one persistence unit in the persistence.xml that points to the same EntityManagerFactory? I was thinking of having one PersistenceContext (Seam-managed PC - an extended PC which is conversation-scoped) which uses one PU and reserving the other PC for the modalPanel forms and backing beans (SFSBs).
    The reason I needed to use this solution/approach is so that when using Hibernate MANUAL flush with SMPC, I can achieve isolated synchronization of the PersistenceContext without updating values in the modalPanel forms and vice versa.
    Any tips on best practices or alternative solutions? thx.
    persistence.xml snippet:
       <persistence-unit name="boBETS">
          <provider>org.hibernate.ejb.HibernatePersistence</provider>
          <jta-data-source>java:/boBETSDatasource</jta-data-source>
          <properties>
             <property name="hibernate.dialect" value="org.hibernate.dialect.SQLServerDialect"/>
             <!-- <property name="hibernate.hbm2ddl.auto" value="validate"/>   -->
             <property name="hibernate.show_sql" value="true"/>
             <property name="hibernate.format_sql" value="true"/>
             <property name="hibernate.generate_statistics" value="true"/>
             <property name="jboss.entity.manager.factory.jndi.name" value="java:/boBETSEntityManagerFactory"/>
             <property name="hibernate.default_catalog" value="boBETS"/>
             <property name="hibernate.default_schema" value="dbo"/>
          </properties>
       </persistence-unit>
       <!-- using boBETS2 for ListValueParamAction for now! trying to isolate the em.flush() such that we can achieve atomic conversations for the
       base form as well as the popup form! -->   
       <persistence-unit name="boBETS2">
          <provider>org.hibernate.ejb.HibernatePersistence</provider>
          <jta-data-source>java:/boBETSDatasource</jta-data-source>
          <properties>
             <property name="hibernate.dialect" value="org.hibernate.dialect.SQLServerDialect"/>
             <!-- <property name="hibernate.hbm2ddl.auto" value="validate"/>   -->
             <property name="hibernate.show_sql" value="true"/>
             <property name="hibernate.format_sql" value="true"/>
             <property name="hibernate.generate_statistics" value="true"/>
             <property name="jboss.entity.manager.factory.jndi.name" value="java:/boBETS2EntityManagerFactory"/>
             <property name="hibernate.default_catalog" value="boBETS"/>
             <property name="hibernate.default_schema" value="dbo"/>
          </properties>
       </persistence-unit>What happens if I were to have 10 PUs and 10 PCs in the same app? Whether they're all pointing to same DB or not. What's the consequence of using "too many"?

    Yes, you can use multiple iCloud accounts in multiple User Accounts on one computer, but, as you know not multiple iTunes Match accounts. Keep in mind that the two services are not the same.
    Since you've posted your question to the iTunes Match forum, which it really doesn't pertain to, you might want to also post it to the iCloud on my Mac forum.

  • Use more than one Catalog from ECC 6

    At the configuration point in ECC 6 Materials Management ... Web Services: ID and Description I can describe more than one catalog URL address , but the user see in transaction ME21N or ME51N only that catalog with the default flag.
    Is it possible to use more than one catalog by these SAP standard functionality?

    Hi Markus,
    no!
    Unfortunatly, it is just posible to use ONE catalogue. At the beginning of development there was kept open the posibilitiy to make posible the use several catalogues in a later state.  That`s mainly the reason why more than one can be entered in customizing. But the functionality of using more than one was never developed later on.
    best regards,
    Angela

  • Using more than one computer...

    I've been trying to wrap my head around syncing using more than one computer and want to see if I have it right.
    Obviously the easiest arrangement is to have one computer and one iphone (and if you want, one mobileme acct) and keep them in sync in all departments.
    Most people have more complicated lives.
    When there is more than one computer involved the basic idea is that all media and apps can only come from one computer. That is the computer/itunes program associated with the iphone.
    When it comes to a second computer, one can still sync contacts, calendars, (notes? bookmarks?) but no media/apps.
    That is to say, you can't download a podcast or song on the second computer and get it onto your iphone without erasing your iphone media library.
    Is that the basic idea? A distinction between media/software and data?
    One grey area: Can voice memos be moved from an iphone onto a second computer without losing media?
    Thanks,
    D.

    If you sync to a computer without media, it will wipe all media off the phone. It's easier to stick to one computer. If you want to sync other things, calendars etc it's better to do it via WiFi or Data.

Maybe you are looking for