I want the query for this scenario will be someone help me?
I have two tables table of markets and purchase...When a record is there in the market table, this means that pure Price shud be replaced by Mkt Price
When I take the records between two particular date
I shud get the mkt price if a record exists for a date between and to date in the table of mkt else I shud get price pure himself.
How can I do this?
Table Purchase
Code date pure price
A 2 01/01/2010
A 3 01/05/2010
A 4 10/01/2010
A 6 15/01/2010
B 15 15/01/20110
Table of markets
Code Date Mkt price
A 10 01/05/2010
A 5 01/12/2010
When I take the records between 01/01/2010 and 01/04/2010
my result should be as follows
A 2 01/01/2010
01/01/2010 and 01/10/2010
A 01/01/2010 * 10 *.
A 01/05/2010 * 10 *.
A 4 10/01/2010
01/01/2010 and 01/15/2010
A 01/01/2010 * 5 *.
A 01/05/2010 * 5 *.
01/10/2010 * 5 *.
A 6 15/01/2010
B 15 15/01/20110
Try this... NVL may not work in a scenario... also, if date of purchase is greater than the date of the contract, then he should show the purchase price and no market prices.
PRAZY@11gR1> exec :from_date:='01/01/2010';
PL/SQL procedure successfully completed.
Elapsed: 00:00:00.00
PRAZY@11gR1> exec :to_date:='04/01/2010';
PL/SQL procedure successfully completed.
Elapsed: 00:00:00.00
select a.code,a.pur_date,
case when pur_date <= mkt_date then
DECODE(mkt_price,0,pur_price,mkt_price)
else
pur_price
end price
from purchase_table a left outer join
(
select code,mkt_price,mkt_date from
(
select code,
mkt_price,mkt_date,
row_number() over (partition by code order by mkt_date desc) rn
from market_table
where mkt_date between to_date(:from_date,'DD/MM/YYYY') and to_date(:to_date,'DD/MM/YYYY')
)
where
rn=1
) b
on a.code = b.code
where a.pur_date between to_date(:from_date,'DD/MM/YYYY') and to_date(:to_date,'DD/MM/YYYY')
order by a.code,a.pur_date
/
C PUR_DATE PRICE
- --------- ----------
A 01-JAN-10 2
Elapsed: 00:00:00.00
PRAZY@11gR1> exec :to_date:='10/01/2010';
PL/SQL procedure successfully completed.
Elapsed: 00:00:00.00
PRAZY@11gR1> /
C PUR_DATE PRICE
- --------- ----------
A 01-JAN-10 10
A 05-JAN-10 10
A 10-JAN-10 4
Elapsed: 00:00:00.00
PRAZY@11gR1> exec :to_date:='15/01/2010';
PL/SQL procedure successfully completed.
Elapsed: 00:00:00.01
PRAZY@11gR1> /
C PUR_DATE PRICE
- --------- ----------
A 01-JAN-10 5
A 05-JAN-10 5
A 10-JAN-10 5
A 15-JAN-10 6
B 15-JAN-10 15
Elapsed: 00:00:00.01
PRAZY@11gR1>
Decode added printing the purchase price if the market price is 0.
HTH,
Prazy
Published by: Prazy on April 21, 2010 15:32
Tags: Database
Similar Questions
-
Name ID Startdate Enddate
AMIT a 1st October 09 3 October 09
AMIT a 3 October 09 5 October 09
AMIT B 5 October 09
BANU C 1st October 09 3 October 09
BANU D 3 October 09
CAREN E 1st October 09 2 October 09
CAREN F 2 October 09 5 October 09
CAREN E 5 October 09
Required result
Name ID Date
AMIT 5 October 09
AMIT B
BANU C 3 October 09
BANU D
CAREN E 2 October 09
CAREN F 5 October 09
CAREN E
My required result is I should list the names that changed the ids.for for example if amit is having has as ID in the third row the name should not be displayed in the result itself because amit is having the same ID.
How to query for this scenario?
-
How to set the font for this SuperNova will display the text properly
I have a problem with the use of Firefox with Supernova. Supernova is a program for the Visual disabled allowing you to enlarge the office. When you visit the page
you will see orange colored text in the main text block. It appears correctly. However when I enlarge the screen with Supernova this orange text is barely readable due to the fact that the letters seems constructed points instead of a smooth line.
Note that this happens even with this page where I enter these details of the issues. Supernove enlarged rhe screen, texts outside of the text box are horrible while the text in this text box is good.
I ask this question here because when I use Internet explore this problem does not occur.
I tried to make a screenshot, but the screenshot feature only "sees" the screen is enlarged. So when I zoom to 100% with Supernova, the text in the screenshot seems to agree.
I realize that this is a difficult question to reproduce, but any help is welcome. Note that it is not a real option for me to enlarge the font with the Firefox options. Supernova expands the full screen, not only the text on the Web page. In this way, I am also able to see the menu / bookmarks of Firefox itself.
Thank you very much
HansYou can use an extension to set a page zoom and the size of the default font on the web pages.
Try disabling hardware acceleration in Firefox.
- Tools > Options > advanced > General > Browsing: "use hardware acceleration when available.
- https://support.Mozilla.org/KB/troubleshooting+extensions+and+themes
-
I have been using Photoshop CS6 and all of a sudden when I try to open the images with this it takes me to a page saying Photoshop CS6 Extedned and asks me to put this software under license. Ive already got Photoshop so why this phenomenon happens? I now can not access?
You should see a prompt to "this software license. You can see on the screen of the trial.
Click on that, you identify if requested, and then click the option "I have a serial number" or you may be able to do so directly.
After you have entered your serial number, your software is licensed and active.
-
How to make the simple query for this scenario... ?
Hello:
Dummy table provided for simplicity.
It's my database table (Table_A)
Date1 | Plane1 | Category | Duration | Fees
01/01/2011 | A | Gold | 5. 2
01/01/2011 | C | Money | 4. 11
01/01/2011 | B | Gold | 6. 2
01/01/2011 | D | Gold | 2. 4
01/01/2011 | B | Gold | 3. 5
01/01/2011 | A | Money | 4. 8
01/01/2011 | B | Gold | 1. 3
I need to write a query to get the result below:
Date1 | Plane1 | Sum_Duration | Sum_Charge | Sum_Gold_Duration | Sum_Gold_Charge | Sum_Silver_Duration | Sum_Silver_Charge
01/01/2011 | A | 9. 10. 5. 2. 4. 8
01/01/2011 | B | 10. 10. 10. 10. 0 | 0
01/01/2011 | C | 4. 11. 0 | 0 | 4. 11
01/01/2011 | D | 2. 4. 2. 4. 0 | 0
This query will provide the 1st four columns:
SELECT Date1,
base1,
Sum (Duration) Sum_Duration,
Sum (load) Sum_Charge
FROM TABLE_A
GROUP BY date1, rarateplan
But I need to know how to get the rest of the columns (i.e. Summary according to categories; from 5 to 8 columns)? Is this can be done in a single query without writing subqueries?
Please let me know, (with code), the best way.
Thank you-
TanvirUse like this:
SELECT Date1,
base1,
Sum (Duration) Sum_Duration,
Sum (load) Sum_Charge,
SUM (decode(Category,'Gold',duration,0)) Sum_Gold_Duration,
SUM (decode(Category,'Gold',charge,0)) Sum_Gold_charge,
SUM (decode(Category,'Silver',duration,0)) Sum_Silver_Duration,
SUM (decode(Category,'Silver',charge,0)) Sum_Silver_charge
FROM TABLE_A
GROUP BY date1, rarateplanPublished by: SANT007 on August 11, 2011 11:04
-
What should be the query for this?
Hello world
My version of DB is
Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - 64bi PL/SQL Release 10.2.0.1.0 - Production "CORE 10.2.0.1.0 Production" TNS for Linux: Version 10.2.0.1.0 - Production NLSRTL Version 10.2.0.1.0 - Production
The table creation script.
CREATE TABLE COUNTRY_SAMPLE ( COUNTRY_ID NUMBER(4,0), COUNTRY_SHORT_NAME VARCHAR2(10 BYTE), COUNTRY_FULL_NAME VARCHAR2(20 BYTE)) ;
The INSERT commands.
Insert into COUNTRY_SAMPLE (COUNTRY_ID,COUNTRY_SHORT_NAME,COUNTRY_FULL_NAME) values (1,'IND','INDIA'); Insert into COUNTRY_SAMPLE (COUNTRY_ID,COUNTRY_SHORT_NAME,COUNTRY_FULL_NAME) values (2,'PAK','PAKISTAN'); Insert into COUNTRY_SAMPLE (COUNTRY_ID,COUNTRY_SHORT_NAME,COUNTRY_FULL_NAME) values (3,'ENG','ENGLAND'); Insert into COUNTRY_SAMPLE (COUNTRY_ID,COUNTRY_SHORT_NAME,COUNTRY_FULL_NAME) values (4,'AUS','AUSTRALIA');
So, how pair these countries, so that they will appear something like this
IND, PAK
IND, ENG.
IND, AUS
-----------------------------------------
PAK, ENG
PAK, AUS
PAK, IND
and so on...
Kind regards
BS2012.
Cross join?
SQL > select a.country_short_name
2, b.country_short_name
3 country_sample one
4 cross
5 join country_sample b
where the 6 a.country_short_name! = b.country_short_name
7.COUNTRY_SH COUNTRY_SH
---------- ----------
IND PAK
ENG IND
AUS IND
IND PAK
PAK ENG
PAK AUS
ENG IND
PAK ENG
ENG AUS
AUS IND
AUS PAK
AUS ENG12 selected lines.
-
Message says that my browser does not recognize the password
Please, the error verbatim.
-
I try to sync my MS Outlook calendar & contacts to icloud/iphone, ipad. Now icloud holds my calendar and contacts, but when I try to set up an appointment, I get the dreaded message that it is not in the calendar for this account & will not be counted.
My schedule is extremely important as are my contacts. How to export the icloud to get back them to outlook. I use MS Outlook 2010. I can't put the icloud as my default - Help
Which calendar you use, there will be two, one to iCloud and who is not, you must be in the iCloud calendar
-
I bought a Xbox 360 for Windows gamepad, as well as a Play and Charge kit. If I want the charge with this kit controller, can I use a USB/power Apple to the charge controller plug?
Hi Arvin,
The question you posted would be better suited in the Xbox Forums. I would recommend posting your query in the Xbox Forums.
Welcome to the Xbox support
http://support.Xbox.com/en-us/
Hope this information helps.
-
This week (01/10/12) I registered on youtube and now I can't log back in here or in my gmail account. I tried every fix-it/single remedy offered the FF forum but nothing works.
Any other work, all the sites that I frequent load fine, is youtube doing something on purpose for FF users? I can get the page youtube videos and see, but I can't log on, every time I click the sign in button, I get:
"The page is not redirecting properly".
Firefox has detected that the server is redirecting the request for this address in a way that will never complete.
This problem can sometimes be caused by disabling or refusing to accept cookies. »
I hate to be a conspiracy theorist, I can connect to youtube without problem on IE, but I hate this browser. I use windows 7 and 15 FF. Can someone find it?
Looks like it's a firefox issue, because that never happened on IE, Safari or Opera on me.
You think not that a simple patch can solve this problem. I have to delete individual cookies every day. -
I was watching www.ustream.tv/decoraheagles for months. I started using Firefox about a month ago. Earlier today, when I tried connecting to the site, I received the message "Firefox has detected that the server redirects the request for this address in a way that will never end."
I went on your site and follow the instructions. This Web site was not in the blocked sites. He told me how to add it, and I did.
She still refuses to open this site.
Internet Explorer WILL open this site.Clear the cache and cookies from sites that cause problems.
"Clear the Cache":
- Tools > Options > advanced > network > storage (Cache) offline: 'clear now '.
'Delete Cookies' sites causing problems:
- Tools > Options > privacy > Cookies: "show the Cookies".
-
"The page isn't redirecting properly?
i receive this warning on a daily basis. it seems to occur whenever i open a message in gmail or try to send a message. anybody have a clue about this? thanks!
Firefox has detected that the server redirects the request for this address in a way that will never end.
* This problem can sometimes be caused by disabling or refusing to accept cookies.
See http://kb.mozillazine.org/The_page_is_not_redirecting_properly
-
EventID: 1206 Event Source: Active Directory Web Services ADWS failed to determine whether the computer is a global catalog server. What will be the solution for this.
Hi K jtm,.
Your question of Windows is more complex than what is generally answered in the Microsoft Answers forums. It is better suited for the IT Pro TechNet public. Please post your question in the TechNet Forum. You can follow the link to your question:
http://social.technet.Microsoft.com/forums/en/category/WindowsServer/ -
For awhile, I got the dialog box with «security alert "revocation information for the security for this site certificate not available.» Do you want? [Yes] [No] [View the certificate] ". » I know that many, if not all, sites are OK because I used them several times in the past.
I tried different "fixed" found by Google "revocation information" and nothing solves the problem - what is.
When I try to make various updates, not related to this problem, I can not download updates due to a security problem.
Suggestions for a computer challenged the user? Thank you.
Richard
http://www.brighthub.com/Internet/Security-Privacy/articles/82291.aspx
read this, see if he can address your question.
-
Bought the Creative Cloud edition student and Professor (a year) and I am unable to access to this. Have followed the instructions for this up but Adobe Creative cloud will not in fact open to install selections.
White screen
https://forums.Adobe.com/thread/1249756
Does not open App | Wheels of progress turn continuously
https://helpx.Adobe.com/creative-cloud/KB/creative-cloud-app-doesn ' t - open.html
Creative cloud Installer hangs
Maybe you are looking for
-
At present, in a machine I use 1500 PA ADDI - DATA digital i/o Card. I think to change the card of NEITHER. I searched the site NEITHER but could not get a similar. ID: Digital i/o board, opto-isolated, 32 e / s digital, 24 V All cards OR are 5 v / T
-
Unable to get the basic unit of the stainless steel bracelet
Hi, I am unable; e of pop on the basic unit of the steel stainless bracelet body. I couldn't find anything online that shows the process. In addition, can I exchange the strap metallic with leather and other straps? where can I buy these? Concerning
-
Undo changes after Windows updates
Original title: Windows 7 Home Premium On 9 September, some updates have been installed on my computer and it resulted in changes basically what Web sites look like. How can I reverse them?
-
How to create such a list... Put the Image and the name of a cell in the list
-
trying to jquery mobile (alpha2) working in a Blackberry widget
Sorry, I'm rather new with widget development. I try to get mobile jquery working in a widget on a blackberry 9780.If anyone has tried it, please let me know if it is worth. My first question was that jquery uses dashes in filenames, which seemsbe ba