How to find if same book is purchased in two years.

Hi all,
I need to find out which books are sold in both 2005 and 2007 only.
create table books
(book_id number,
name varchar2(20),
purchase_date date);
begin
insert into books values (1,'Oracle','22-jan-01');
insert into books values (1,'Oracle','22-mar-05');
insert into books values (1,'Oracle','14-feb-07');
insert into books values (2,'Java','27-sep-03');
insert into books values (2,'Java','21-oct-05');
insert into books values (3,'Sap','12-dec-04');
insert into books values (3,'Sap','14-nov-05');
insert into books values (4,'Unix','19-apr-05');
insert into books values (4,'Unix','30-may-07');
end;
Expected output
1 Oracle 22-MAR-05
1 Oracle 14-FEB-07
4 Unix 19-APR-05
4 Unix 30-MAY-07
We have one more book of Oracle purchased in 2001, i don't what that in my output.
Only books purchased in both 2005 and 2007 should be in the output result.
Please help me how my query should be.
Thanks
Raghu

There are a variety of ways. Something like
SQL> ed
Wrote file afiedt.buf
  1  SELECT b.*
  2    FROM books b,
  3         (SELECT book_id
  4           FROM books
  5          WHERE extract( year from purchase_date ) = 2005
  6         INTERSECT
  7         SELECT book_id
  8           FROM books
  9          WHERE extract( year from purchase_date ) = 2007) purchases
10   WHERE b.book_id = purchases.book_id
11*    AND extract( year from b.purchase_date) IN (2005,2007)
SQL> /
   BOOK_ID NAME                 PURCHASE_
         1 Oracle               22-MAR-05
         1 Oracle               14-FEB-07
         4 Unix                 19-APR-05
         4 Unix                 30-MAY-07Justin

Similar Messages

  • How do I view a book I purchased at Itunes on my computer

    How do I view a book I purchased at Itunes on my computer

    Rocha2 wrote:
    How do I view a book I purchased at Itunes on my computer
    You can't even view an Apple iBook on a Mac, much less a PC!  They are only for use on Apple iOS devices.
    Most people would be much better off buying electronic books from the Amazon Kindle store.  Through the use of the Kindle apps, Kindle books can be read on iOS devices,  Kindle readers, computers, etc.  They are much more useful than Apple's iBooks.

  • TS1702 how to find the serial number, after purchase Pages online?

    how to find the serial number, after purchase Pages online?

    If you downloaded the standalone trial version of Lightroom, it will be necessary for you to uninstall that version. Then you will be able to install Lightroom through the creative cloud application manager. After you install Lightroom that way, just double-click on the catalog that you have already started.

  • How do i transfer a book i purchased on my phone to my macbook?

    how do i transfer a book i purchased in iTunes on my phone to my mac book?

    Follow the instructions here or here.
    (126878)

  • How to find the difference in object definition between two databases

    Hi,
    Can any one suggest me how to find the difference in object definition between two different databases. Is there any tool or by OEM? If so how?
    Regards
    Naveen

    this link may be helpful...
    http://www.dbspecialists.com/scripts.html

  • HT4009 How do I get a refund on in app purchases my two year old made?

    How do i get a refund on an in-app purchase my two year old made? HELP!

    All purchases are considered final, but you can try the 'report a problem' link to contact iTunes Support and see if they will refund or credit you : http://reportaproblem.apple.com
    If the 'report a problem' link doesn't work then you can try contacting iTunes Support via this page : http://www.apple.com/support/itunes/contact/ - click on Contact iTunes Store Support on the right-hand side of the page, then Purchases, Billing & Redemption
    To try and stop it happening again you can use Settings > General > Restrictions on your phone to turn off in-app purchases and to require your password to be entered for every download (the default is a 15 minute period during which it doesn't need re-entering)

  • HT1918 How do I return a book I purchased by accident

    I Accidentally purchased the GAME OF THRONES series. I don't know how to return it. HELP... How do I return a book that was accidenta purchased?

    Click here and ask the iTunes Store staff for a refund.
    (119472)

  • How to find the Invoice available for Purchase orders

    Hi friends,
    How to find the Invoice available for PO. Please give me the tcodes also.
    Is one PO can have multiple Invoice, then what is the relation between those PO and Invoices.
    Thanks,
    Veerendra.

    Hi,
    Goto ME23N and in the line item choose the PO History tab..
      There you can check if there is any invoice created for that PO..
      Yes one PO can have multiple invoices...
      Check the table RSEG where it has references to a PO and PO line items..
    THanks,
    Naren

  • TS1424 I cant find the audio books i purchased on my phone or the itune store sine the updated ios6

    How do I get the audiobooks I purchased back on my iphone??

    I guess you can try contacting Apple through iTunes Store Support. and seeing if they will allow you to re-download them.

  • How to find growth difference between the employees in different year

    Hi All,
    I have one table. In that how I can find the growth of employees between two years means suppose there are
    100 employees in 2009 and now 50 more added in 2010.then can anyone tell me the sql query how i can find that difference and i have to also store that result in a variable.
    Edited by: user13310428 on Aug 2, 2010 10:21 PM

    Can you try below query
    SQL> ed
    Wrote file afiedt.buf
      1  with c as
      2  (select 2009 yy, 100 cnt from dual union all
      3  select 2010 , 150 from dual)
      4  select yy, cnt-prev Diff
      5  from
      6  (
      7  select yy,cnt, lag(cnt) over (order by yy) prev
      8  from c
      9* )
    SQL> /
            YY       DIFF
          2009
          2010         50If you want to show growth in % also, you can use
    with c as
    (select 2009 yy, 100 cnt from dual union all
    select 2010 , 150 from dual)
    select yy,cnt-prev Diff,(cnt-prev)/prev growth
    from
    select yy,cnt, lag(cnt) over (order by yy) prev,lead(cnt) over (order by yy) nxt
    from c
    SQL> /
            YY       DIFF     GROWTH
          2009
          2010         50         .5

  • How to do the same form element alignments on two different regions

    Hi,
    I have two different regions on the same page as the second one is underneath of the first one. Both the regions have some form elements like text field, select list etc. However the alignment of the elements on these two regions are not the same. In the individual regions, it just aligns the input fields based on the maximum length of the label within the region only, so it creates two different vertical alignments per region. How to have the same alignment for the input elements across the regions?
    (I wish to upload the screenshot of the page but there is no provision in this forum to do so).
    Thanks in advance.
    Natarajan

    The basic approach is to set the width of the item labels using a CSS embedded style sheet in the page HTML Header:
    <style type="text/css">
    label {
      display: block;
      width: 15em;
    </style>If you want to limit this to items in specific regions, then give these region(s) static region IDs (such as <tt>region-1</tt>) for use as CSS selectors:
    <style type="text/css">
    #region-1 label,
    #region-2 label {
      display: block;
      width: 15em;
    </style>

  • Where do I find my audio books after purchase?

    Once I downloaded latest update on my new iPad I can no longer find my new audio book purchases to play.  Any help?

    I did the same thing as you did and mine show up under Audiobooks on my iPhone. I would maybe try doing a search on the iPhone for the audiobook (swipe down on screen) and type in the audiobook to see if you can find the lcoation of the audiobook.

  • How do I hide magazines/books from purchased items?

    I have tried to delete past magazines and books but it seems it´s not possible and the only thing that can be done is hiding them. I have searched on how to do it but since the ibooks got separated from iTunes it´s not the same. Can anyone help me hide the magazines (from Newstand) and books I no longer want? I don´t want them to appear on my purcharse history too if possible.

    Hey there aj133,
    It sounds like there are some purchases you want to have hidden from others on your Family Shared account. Once you have the content downloaded onto the device(s) you want them on, you can use this article to hide them. Hiding them does not remove them from devices they are already downloaded to:
    iTunes Store: Hiding and unhiding purchases
    Hide your purchases
    Open iTunes on your Mac or PC.
    From the Store menu, choose Store > Sign In, and then enter your Apple ID and password.
    Go to the iTunes Store.
    Click Purchased from the Quick Links section on the right side of the iTunes Store.
    Choose a content type by clicking Music, Movies, TV Shows, Apps, or Books from the top of the window.
    A list of your purchased items for the content type you are viewing will appear. Mouse over the item you want to hide until an X appears its top-left corner.
    A confirmation dialog will appear once you click the X.
    Thank you for using Apple Support Communities.
    Regards,
    Sterling

  • How to find out what is the purchase price keyed in Initial Quantity

    Dear Experts,
    The stock valuation is Standard Costing.
    Before this, someone else keyed in initial quantity and the purchase price in the Initial Quantities module.
    Now when I issued a PO to a vendor (price list tagged with Last Purchase Price), the price shown is different.
    How do I find out if the price keyed in initial quantity is correct or not? Any tables I can refer to?
    I tried to track from the Inventory Posting List and the smartlink only bring me to the journal entry for the initial quantity posting. I don't have the details like item no., qty, price.\
    Thanks in advance.

    Hi Joyce,
    Go to Inventory->Inventory transactions->Initial Quantities, Inventory Tracking, and Inventory Posting. Open Inventory Posting Tab and select your price list and items if you want or check you can see there Item quantity and old price also price list wise.
    Thanks
    Sachin

  • Why can't I find an audio book I purchased to download to my library?

    A few years ago I purchase an audio book with an itunes gift card. I recently got a new PC and when I tried to transfer my purchases to the computer most of them transfered without any problem. However, two of my audio books did not. Any ideas how to correct this?

    oops, I found it in somebody elses question.

Maybe you are looking for