Count (*) that is a conditional statement and then if the result
HI: This is table_1:with Table_1
as
(
select to_date('01-JUL-2009 20:10','DD-MON-YYYY HH24:MI') incident_date, 2005 Policy_no from dual
union all
select to_date('04-MAR-2009 12:12','DD-MON-YYYY HH24:MI') incident_date, 2009 Policy_no from dual
union all
select to_date('25-JUL-2010 23:30','DD-MON-YYYY HH24:MI') incident_date, 2013 Policy_no from dual
)
select * from Table_1
with Table_2
as
(
select to_date('01-JUL-2009 20:10','DD-MON-YYYY HH24:MI') Cover_start_date, to_date('04-JUL-2009 20:10','DD-MON-YYYY HH24:MI') Cover_end_date, 2005 Policy_no, 100 agr_line_no, 'BIKE' object from dual
union all
select to_date('01-JUL-2009 20:10','DD-MON-YYYY HH24:MI') Cover_start_date, to_date('04-JUL-2009 20:10','DD-MON-YYYY HH24:MI') Cover_end_date, 2005 Policy_no, 200 agr_line_no, 'BUCKS' from dual
union all
select to_date('01-JUL-2009 20:10','DD-MON-YYYY HH24:MI') Cover_start_date, to_date('04-JUL-2009 20:10','DD-MON-YYYY HH24:MI') Cover_end_date, 2005 Policy_no, 300 agr_line_no, 'CELL' from dual
union all
select to_date('01-JUL-2009 20:10','DD-MON-YYYY HH24:MI') Cover_start_date, to_date('04-JUL-2009 20:10','DD-MON-YYYY HH24:MI') Cover_end_date, 2005 Policy_no, 400 agr_line_no, 'CAR' from dual
union all
select to_date('01-JUL-2009 20:10','DD-MON-YYYY HH24:MI') Cover_start_date, to_date('04-JUL-2009 20:10','DD-MON-YYYY HH24:MI') Cover_end_date, 2005 Policy_no, 500 agr_line_no, 'HOUSE' from dual
union all
select to_date('01-MAR-2009 20:10','DD-MON-YYYY HH24:MI') Cover_start_date, to_date('09-MAR-2009 20:10','DD-MON-YYYY HH24:MI') Cover_end_date, 2009 Policy_no, 100 agr_line_no, 'BIKE' object from dual
union all
select to_date('01-MAR-2009 20:10','DD-MON-YYYY HH24:MI') Cover_start_date, to_date('09-MAR-2009 20:10','DD-MON-YYYY HH24:MI') Cover_end_date, 2009 Policy_no, 200 agr_line_no, 'BUCKS' from dual
union all
select to_date('01-MAR-2009 20:10','DD-MON-YYYY HH24:MI') Cover_start_date, to_date('09-MAR-2009 20:10','DD-MON-YYYY HH24:MI') Cover_end_date, 2009 Policy_no, 300 agr_line_no, 'BEACH' from dual
union all
select to_date('01-MAR-2009 20:10','DD-MON-YYYY HH24:MI') Cover_start_date, to_date('09-MAR-2009 20:10','DD-MON-YYYY HH24:MI') Cover_end_date, 2009 Policy_no, 400 agr_line_no, 'CAR' from dual
union all
select to_date('01-MAR-2009 20:10','DD-MON-YYYY HH24:MI') Cover_start_date, to_date('09-MAR-2009 20:10','DD-MON-YYYY HH24:MI') Cover_end_date, 2009 Policy_no, 500 agr_line_no, 'HOUSE' from dual
union all
select to_date('20-JUL-2009 20:10','DD-MON-YYYY HH24:MI') Cover_start_date, to_date('29-JUL-2009 20:10','DD-MON-YYYY HH24:MI') Cover_end_date, 2013 Policy_no, 676 agr_line_no, 'CAR' from dual
)
select * from Table_2
I need to perform a count (*) on agr_line_no on the condition that there is other other objects 'CAR' that is to say if forpolicy_no = 2005 the count should be 4.Be Table_1 to table_2 on Policy_no and all columns in table_1 must be selected as well as an additional column called Object_many.
Object_many is based on the count (*) from table_2 it is if the number is > 1, 'Y' must be returned to another "n".
Also, there must be a clause where clause that is to say when table_1.incident_date between .cover_start_date table_2 and table_2 .cover_end_date
Final result should look like this
with Table_1
as
(
select to_date('01-JUL-2009 20:10','DD-MON-YYYY HH24:MI') incident_date, 2005 Policy_no, 'Y' Object_many from dual
union all
select to_date('04-MAR-2009 12:12','DD-MON-YYYY HH24:MI') incident_date, 2009 Policy_no, 'Y' Object_many from dual
union all
select to_date('25-JUL-2010 23:30','DD-MON-YYYY HH24:MI') incident_date, 2013 Policy_no, 'N' Object_many from dual
)
select * from Table_1
Thanks in advance!Banner:
Oracle Database 11 g Release 11.2.0.2.0 - 64 bit Production
PL/SQL Release 11.2.0.2.0 - Production
"CORE 11.2.0.2.0 Production."
AMT for Linux: Version 11.2.0.2.0 - Production
NLSRTL Version 11.2.0.2.0 - Production
with Table_1
as
(
select to_date('01-JUL-2009 20:10','DD-MON-YYYY HH24:MI') incident_date, 2005 Policy_no from dual
union all
select to_date('04-MAR-2009 12:12','DD-MON-YYYY HH24:MI') incident_date, 2009 Policy_no from dual
union all
select to_date('25-JUL-2010 23:30','DD-MON-YYYY HH24:MI') incident_date, 2013 Policy_no from dual
), Table_2
as
(
select to_date('01-JUL-2009 20:10','DD-MON-YYYY HH24:MI') Cover_start_date, to_date('04-JUL-2009 20:10','DD-MON-YYYY HH24:MI') Cover_end_date, 2005 Policy_no, 100 agr_line_no, 'BIKE' object from dual
union all
select to_date('01-JUL-2009 20:10','DD-MON-YYYY HH24:MI') Cover_start_date, to_date('04-JUL-2009 20:10','DD-MON-YYYY HH24:MI') Cover_end_date, 2005 Policy_no, 200 agr_line_no, 'BUCKS' from dual
union all
select to_date('01-JUL-2009 20:10','DD-MON-YYYY HH24:MI') Cover_start_date, to_date('04-JUL-2009 20:10','DD-MON-YYYY HH24:MI') Cover_end_date, 2005 Policy_no, 300 agr_line_no, 'CELL' from dual
union all
select to_date('01-JUL-2009 20:10','DD-MON-YYYY HH24:MI') Cover_start_date, to_date('04-JUL-2009 20:10','DD-MON-YYYY HH24:MI') Cover_end_date, 2005 Policy_no, 400 agr_line_no, 'CAR' from dual
union all
select to_date('01-JUL-2009 20:10','DD-MON-YYYY HH24:MI') Cover_start_date, to_date('04-JUL-2009 20:10','DD-MON-YYYY HH24:MI') Cover_end_date, 2005 Policy_no, 500 agr_line_no, 'HOUSE' from dual
union all
select to_date('01-MAR-2009 20:10','DD-MON-YYYY HH24:MI') Cover_start_date, to_date('09-MAR-2009 20:10','DD-MON-YYYY HH24:MI') Cover_end_date, 2009 Policy_no, 100 agr_line_no, 'BIKE' object from dual
union all
select to_date('01-MAR-2009 20:10','DD-MON-YYYY HH24:MI') Cover_start_date, to_date('09-MAR-2009 20:10','DD-MON-YYYY HH24:MI') Cover_end_date, 2009 Policy_no, 200 agr_line_no, 'BUCKS' from dual
union all
select to_date('01-MAR-2009 20:10','DD-MON-YYYY HH24:MI') Cover_start_date, to_date('09-MAR-2009 20:10','DD-MON-YYYY HH24:MI') Cover_end_date, 2009 Policy_no, 300 agr_line_no, 'BEACH' from dual
union all
select to_date('01-MAR-2009 20:10','DD-MON-YYYY HH24:MI') Cover_start_date, to_date('09-MAR-2009 20:10','DD-MON-YYYY HH24:MI') Cover_end_date, 2009 Policy_no, 400 agr_line_no, 'CAR' from dual
union all
select to_date('01-MAR-2009 20:10','DD-MON-YYYY HH24:MI') Cover_start_date, to_date('09-MAR-2009 20:10','DD-MON-YYYY HH24:MI') Cover_end_date, 2009 Policy_no, 500 agr_line_no, 'HOUSE' from dual
union all
select to_date('20-JUL-2009 20:10','DD-MON-YYYY HH24:MI') Cover_start_date, to_date('29-JUL-2009 20:10','DD-MON-YYYY HH24:MI') Cover_end_date, 2013 Policy_no, 676 agr_line_no, 'CAR' from dual
)
--
-- end-of-test-data
--
select
table_1.policy_no,
max(table_1.incident_date) incident_date,
case when count(table_2.agr_line_no) > 1 then 'Y' else 'N' end object_many
from table_1
left outer join table_2
on table_2.policy_no = table_1.policy_no
and table_2.cover_start_date <= table_1.incident_date
and table_2.cover_end_date >= table_1.incident_date
and table_2.object != 'CAR'
group by
table_1.policy_no
order by
table_1.policy_no;
I assumed policy_no either the primary key in Table_1 - so max (table_1.incident_date) will work.
If you have an index on Table_2 on coverage dates, then the construction above could be better than one between. Otherwise between will be quite OK ;-)
Tags: Database
Similar Questions
-
Find files and then PUT the results?
Is it possible to perform a search and then PUT all the found files (download files from search results)?
I around 255 files in my site updated occasionally to an asset from the library and I can't understand an easy way to download these files on the server without doing it manually on a basis of individual records.
Any ideas?In the files window, click the icon in the upper right (the
"Venetian blind" icon on a PC, in the header with the word "Files" bar)There, select Edit/SelectRecently modified
--
E. Michael Brandt
www.divaHTML.com
divaGPS | divaFAQwww.valleywebdesigns.com
JustSo PictureWindow--
HSMM_Imaging wrote:
> Unfortunately, sync is to find about 2000 update files (which can or)
> not be good to do... not sure because there are multiple users update files.
(> primarily PDF - on the web server).
>
> I want to only download the files that have been disrupted by the library item.
> 2000 vs 255 files are a big difference.
>
> I realize only if I synchronize files and support through the 2000 first
> files, it can be easier as soon as I change the library item. The thing is, I
> know 2000 files are not actually "obsolete." It is only through a server
> local and the changes to the file management that makes things appearing all these files
> need to sync.
>
> Of anyway, if I could download it all the files have only the library item in
> them, it would make things MUCH easier. I was trying to achieve this by making a
> the library item tag search query and then download all the results.
>
> Does not seem that is possible if... or is it?
> -
Is possible to write the INSERT statement that fills two columns: 'word' and 'sense' of the file text with multiple lines - in each line is followed word that is the meaning?
Hello
2796614 wrote:
Is possible to write the INSERT statement that fills two columns: 'word' and 'sense' of the file text with multiple lines - in each line is followed word that is the meaning?
Of course, it is possible. According to what the text file looks like to, you can create an external table that treats the text file as if it were a table. Otherwise, you can always read the file in PL/SQL, using the utl_file package and INSERT of PL/SQL commands.
You have problems whatever you wantt? If so, your zip code and explain what the problem is.
Whenever you have any questions, please post a small example of data (CREATE TABLE and only relevant columns, INSERT statements) for all of the tables involved and the exact results you want from these data, so that people who want to help you can recreate the problem and test their ideas. In this case, also post a small sample of the text involved file.
If you ask about a DML operation, such as INSERT, then INSERT statements, you post should show what looks like the tables before the DML, and the results will be the content of the table changed after the DML.
Explain, using specific examples, how you get these results from these data.
Always say what version of Oracle you are using (for example, 11.2.0.2.0).
See the FAQ forum: Re: 2. How can I ask a question on the forums?
-
I use RemoterVNC on my iPhone to log remotely on my Mac at home so the children can use the computer without my go physically to the computer. (I admit, I am a bit lazy like that). However, lately when I launch RemoterVNC (on my iPhone), do the business of the connection, and then exit the application, the remote Mac began a disconnection. He also started doing this when I connect from my first Mac via screen sharing. It is a relatively recent behavior. Someone has an idea what setting I have (inadvertently) enabled to prevent the computer from automatically disconnect when the 'access app' is no longer active on the remote device?
Go to System Preferences > energy saving > computer sleep > drag it FOREVER to prevent disconnection of your mac.
Think simple.
-
Hi, I use iTunes 12.3.2.35 on a Windows 7 computer. I don't seem to be able to import files from a CD that contains the files on it as mp3 files. If I start iTunes and then put the CD in, it doesn't appear and I can't drag and drop.
It would not seem like an audio CD, as a drive in this way is a data disc when it contains mp3 files. You would need to access the file menu in iTunes, manage files here. If you manually manage music, you will need to access it as a regular folder on your computer. In iTunes, go to file > add file to library, and select individual files.
-
How to ensure that my computer has microphones and then use them for talking to Cortana?
How to ensure that my computer has microphones and then use them for talking to Cortana?
Hi Walter,
Please start by http://windows.microsoft.com/en-us/windows-10/cortana-privacy-faq
Also, try to review this tutorial: http://www.tenforums.com/tutorials/4026-cortana-turn-off-windows-10-a.html
They should help you get started. Problems specific to the micro (existence, activation, volume,...) will be addressed (more than the troubleshooting steps if Cortana doesn't) that you go through the above; However, a "one-stop-shop" for microphones & recognition recording & speech covering all peripheral aspects are versatile control panel page (see the path in the blue header at the top of the screenshot pictured below for W10Pro 11102).
Best wishes
Kosh
-
I can't access my hotmail account more because of a message that tells me to disconnect, and then click my account from Outlook web; which then brings back me to ordinary sign in because I have no direct application on the web.
original title: can connect is more.You have posted the answers Feedback Forum. I'll pass this to the Windows forum space.
I'm not clear on exactly what your problem may be, but I suspect you have find better assistance in the Windows Live forums (which are part of a different forum platform).
Help and Support for Windows Live Hotmail can be found at http://windowslivehelp.com/product.aspx?productid=1
-steve
-
I installed a game for windows XP and then used the troubleshooting tool to convert so that I can play at 7.
It still fails. What should I do? Please answerHello
a. what game do you have installed?
b. do you get errors trying to run the game in compatibility mode?Look for error messages in the event viewer. If you find error messages after return the exact error message so that we can help you better.
Measures to check the application event log:
1. click on start.
2. in the search box type eventvwr.msc, and then on enter.
3. now, click Application in the event viewer (local).
4. now locate the event log on the right side of the event viewer window.http://Windows.Microsoft.com/en-us/Windows7/open-Event-Viewer
http://Windows.Microsoft.com/en-us/Windows7/what-information-appears-in-event-logs-Event-ViewerYou can try to perform the clean boot on your computer and check if that helps.
From your computer by using a minimal set of drivers and startup programs so that you can determine if a background program is interfering with your game or program. This type of boot is known as a "clean boot".
To perform a clean boot on a computer, follow these steps.
1. click on start, type msconfig in the search box and press ENTER.If you are prompted for an administrator password or a confirmation, type the password, or click on continue.
2. in the general tab, click Selective startup.
3. under Selective startup, clear the check box load startup items.
4. click on the Services tab, select the hide all Microsoft Services check box, and then click Disable all.
5. click on OK.
6. When you are prompted, click on restart.
7. after the computer starts, check if the problem is resolved.Please follow the system in the boot environment. If the problem does not occur, it indicates that the problem is related to an application or a service, we have disabled. You can use the MSCONFIG tool again to reactivate the disabled one by one element to find the culprit.
If your issue is resolved, follow the how to determine what is causing the problem section in KB article to narrow down the exact source.
For more information visit: http://support.microsoft.com/kb/331796After you determine the startup item or the service that is causing the problem, contact the manufacturer of the program to determine if the problem can be solved. Or, run the System Configuration utility, and then click to clear the check box of the element of the problem.
To restore your computer to a Normal startup mode, follow these steps:
1. click on start in the box start the search.
2. type msconfig and press ENTER.If you are prompted for an administrator password or a confirmation, type the password, or provide confirmation.
3. on the general tab, click Normal Startup - load all device drivers and services and then click OK.
4. When prompted, click on restart.You can check its compatibility with windows 7 in the Compatibility Center.
http://www.Microsoft.com/Windows/compatibility/Windows-7/en-us/default.aspxHope this information is useful.
-
Hi, my videographer of windows program opens only once. It is impossible to reopen it unless I restart the pc. And then he does that only once and then comes the same problem. Thanks in advance
Just a thought...
It may be interesting to try to open Movie Maker and go to...
Tools / Options / compatibility... tab and left click of the
"Restore all defaults" button / OK. -
Original title: Original Windows XP cd.
I have an original cd of Windows XP Home Edition with the product key for it and want to use it... but when I look at the disk, according to me, he said: "Don't use this CD to reinstall the operating system on Dell count" that I had in 2004 and have more... what I want to know I can install it on a different computer now and it would be legal?
Because Dell SLP, the restriction of similar model is not important. All that matters is the EULA and the fact that the two computers are Dells.
-
It happened once before, but it somehow went away after I restarted my laptop. I restarted my laptop, this time, but it has not worked.
~*~
OK, so I just finished put a video together. It consists of a Hypercam 2 record (which means it's a .avi file), a PNG image, text and a song (which is a WMA file).
~*~
I save the file, and then click Publish Movie. Everything goes well until the last step where the video is actually published. The window made a break for a while before you receive the following message;
~*~
"Cannot complete the movie publish .
The video file cannot be published to the specified location. "Check that the publishing location is still available, that there is enough free space on the disk and then republish the movie again."
~*~
I know there are a lot of free space on the drive on my laptop (it's an Inspiron 1520), and that there is nothing wrong with any of my files. I tried to change places without result. It simply doesn't get it. It would be a great help to me if someone could tell me what is the problem :)
~*~
Thank you very much
Len
Microsoft Windows Movie Maker is not to let me publish my movies
Hello
I suggest you try the steps mentioned in the link given below.
Error message when you try to publish a movie using Windows Movie Maker in Windows Vista: "cannot complete publish movie.
http://support.Microsoft.com/kb/930435
Additional information:
Solve problems with publishing a movie to your computer
-
Original title: Dual boot
My XPpro on a former player, was upward. then, I got another new drive, installed Win7Ultimate. Well, I got the OLD disk works with XP on it. But, some of these apps DO WORK not on Win7. so, at least for now, I have two drives installed on the same computer. is it possible to set up a dual boot, so I don't have to stop, and then pass the SATA cables that I boot to change? Operating systems already are on 2 different disks.
Hello
How to set up a Dual Boot Installation with Windows 7 and XP
http://www.SevenForums.com/tutorials/8057-dual-boot-installation-Windows-7-XP.htmlDefinitive dual-booting guide: Windows 7, Linux, Vista and XP step-by-step
http://apcmag.com/the_definitive_dualbooting_guide_linux_vista_and_xp_stepbystep.htmDual Boot computer preinstalled Windows 7 with XP
http://www.howtogeek.com/HOWTO/8790/dual-boot-your-pre-installed-Windows-7-computer-with-XP/I hope this helps.
--------------------------------------------------------------------------------------------
Rob Brown - Microsoft MVP<- profile="" -="" windows="" experience :="" bicycle="" -="" mark="" twain="" said="" it="">-> -
Original title: invert the selection
In Windows XP, I could choose a file (or files), then go to Edit, and then invert the selection. How do I do that in Windows 7?
I think Alt-E-I is also the shortcut for this feature.
-
Hello! I want to take advantage of the Black Friday for student agreement. However, I already have a plan that ends in a few months. Can I cancel this plan and then use the agreement of Black Friday? Thank you!
Hello
You will need to speak with sales of Adobe for the same thing.
Kind regards
Sheena
-
How do I register a very old acrobat from adobe and then download the upgrade? It seems that the serial number is not consistent with the serial number required by the adobe Web site. My serial number starts with the letter instead numbers.
Please see:
Redeem your student and teacher edition purchase, convert a redemption code to a number of series and much more .
I hope this helps.
Concerning
Megha Rawat
Maybe you are looking for
-
I'm just a matter
-
Carpet * a/Panasonic UJ-830 s satellite L10
Hello I was put in with the carpet * a reader of DVD-RAM UJ-830 s mounted on my Satellite L10 for a few years, because I have used in a extent the laptop somewhere and have had my external USB DVD - RAM drive still available. However; now I am in the
-
New Lenovo Ideapad Z710 friend refuses to install the touchpad driver.
A few weeks ago my friend bought new a laptop Lenovo Ideapad Z710 pre-installed with Win8. I "upgraded" to Windows 7 for him, as none of us can handle the new OS. Usually, I have no trouble to reinstall the drivers after installing a new OS, but for
-
MD3220i - virtual drives Windows 2008 offline
After installation of the MD3220i and the initiator configuration iSCSI, I see the LUNS from storage but they are offline and I can do something with them. Any help?
-
Error message: the Windows Photo Viewer cannot display images because there may not be enough memory available on your computer. Close some programs that you do not use or free up hard disk space and then try again. I got rid of some programs and so