Count the numbers that are used in the range - SQL

Dear Guru,

I need help to create a query.

My INPUT will be as


WITH s AS
(
SELECT 2A, 7B
OF THE DOUBLE
UNION
CHOOSE 3A, 3B
OF THE DOUBLE
UNION
CHOOSE 3 a, 6 b
OF THE DOUBLE
UNION
9. SELECT a, 15B
OF THE DOUBLE
UNION
SELECT 10A, 10B
OF THE DOUBLE
UNION
SELECT 10A, 15B
THE DOUBLE)
SELECT *.
S;

I need output like the distinct number of numbers. Review the column was, as num_from and as num_to b. The output expected here is 13. Since all the numbers from 2 to 15 are in use to expect 8. so, my result would be 13. Kindly help me to reslove.

I am currently working in Oracle database 10g.

Thanks in advance!

Kind regards
VJ

Hello

Maybe not the most elegant, but it should work:

SQL> WITH s AS (
  2    SELECT 2 a, 7 b FROM DUAL UNION
  3    SELECT 3 a, 3 b FROM DUAL UNION
  4    SELECT 3 a, 6 b FROM DUAL UNION
  5    SELECT 9 a, 15 b FROM DUAL UNION
  6    SELECT 10 a, 10 b FROM DUAL UNION
  7    SELECT 10 a, 15 b FROM DUAL
  8  ),
  9  t AS (
 10    SELECT level-1 i
 11    FROM dual
 12    CONNECT BY level <= ( SELECT max(b)-min(a)+1 FROM s )
 13  )
 14  SELECT count(distinct min(a)+i) as cnt
 15  FROM s CROSS JOIN t
 16  GROUP BY a,b,i
 17  HAVING min(a)+i BETWEEN a AND b
 18  ;

       CNT
----------
        13
 

Tags: Database

Similar Questions

  • I need a copy of Visual Studio 2008 while I have the same version of Crystal Reports that are used by one of my clients.

    Buy Visual Studio 2008

    I need a copy of Visual Studio 2008 while I have the same version of Crystal Reports that are used by one of my clients.

    Can I buy Visual Studio 2010 with MSDN Essentials and then download and use Visual Studio 2008

    Hello

    Welcome to Microsoft Windows 7 answers Forum!

    Thank you for visiting the Microsoft answers Forum.

    The question you posted would be better suited in the MSDN Forums. I would recommend posting your query in the MSDN Forums

    I hope this helps.

  • Is it possible to save your project who keeps only files that are used in the order and get rid of files that you do not use?

    my project is at an advanced stage now, a lot of media loaded up and its got to the point where the project keeps "forgetting" his makes (the line goes to yellow when it should be green)

    I assume that this may be due to the face that I have a lot of media loaded upward there now, including many from the effects of exports which should be large enough

    so, I would like to save the project or export the project in such a way so that it retains only the bare minimum of files that im actually... better still, use if she maintained only the part of the files that are used and stripes out of the rest, but maybe it's wishful thinking?

    I also wonder if I could save the project, bringing files in a separate folder, only the files used in the project

    I'd love to, having someone take the time to clear this up for me.  Thank you

    Project Manager in the file Menu

    Backup first carefully!

  • What defines the numbering of the pages on a bunch of files that are used in several Bookfiles?

    I have a bookfile FM 10 called BookfileA with 20 chapters. In Chapter 1, I put the chapter numbering starts at 1 and the numbering to start at 1. In chapters 2 to 20, I put the chapter numbering and numbering of pages to increment from the previous chapter. So far, so good, but here is the problem. .....

    In BookfileB, Chapter 1 is a different and original file Chapter 1 is transferred to Chapter 2. But the chapter of BookfileB 2 is still automatic reinstatement his chapter and the numbering of pages to 1.

    Unusually BookfileB has an additional chapter, do I have to monkey with the chapter numbering whenever I want to generate a Variant or another? Is there something numbering that I do not?

    Define the numbering and pagination of each file in the file of each book, not in individual files. Book settings take precedence over settings files.

    Refresh/update the books whenever you print, as not sure what common files update last book.

  • Report to the size of the list of snapshots that are used by a virtual machine

    I'm looking for to add to my report to the size of all the snapshots that are currently used by each virtual machine.  For example, I'm already reporting on space put into service and used space - but how much space are using snapshots?   Is there a way to get this data using powerCLI?

    Thank you!

    Get-Cluster-name NOMCLUSTER | Get - VM | Select

    Name, MemoryMB NumCpu, Description, PowerState, ProvisionedSpaceGB, UsedSpaceGB, Version, VMHost, ResourcePool,

    @{N = "HDsizeKB"; E={($_. Hard drives | Measure-Object-CapacityKB property-sum). Sum}} folder,.

    @{N = "Datastore"; E={($_ | Get - Datastore). Name}},@{N="#snapshots '; E={($_ | Get - Snapshot). County}},

    @{N = 'Name of the OS'; E={$_. Guest.OSFullName}} | Export-Csv "C:\report.csv" - NoTypeInformation

    The cmdlet Get-SNapshot in PowerCLI 4.1 returns an incorrect value. See the size snapshot by Dimitar and Vitali.

    And they display a script, called getsnapshotsize - 1.ps1 that returns the correct value.

    You can use this script to your script as follows:

    (1) download the script and save it in the directory where your other scripts

    (2) call the script of the post in your script and use the size of return value

    Something like that

    Get-Cluster -Name clustername | Get-VM | select Name,MemoryMB,NumCpu,Description,PowerState,ProvisionedSpaceGB,
         UsedSpaceGB,Version,VMHost,ResourcePool,
         @{N="HDsizeKB";E={($_.Harddisks | Measure-Object -Property CapacityKB -Sum).Sum}},Folder,
         @{N="Datastore";E={($_ | Get-Datastore).Name}},@{N="#Snapshots";E={($_ | Get-Snapshot).Count}},
         @{N="OS Name";E={$_.Guest.OSFullName}},
         @{N="Snapshot size MB";E={(.\getsnapshotsize-1.ps1 $_ | Measure-Object -Property SizeMB -Sum).Sum}}     |`
         Export-Csv "C:\report.csv" -NoTypeInformation -UseCulture
    

    ____________

    Blog: LucD notes

    Twitter: lucd22

  • Why filtering by "unused" shows the files that are used in the project?

    Above the list of clips, I choose 'unused '.  I thought that this would be a practical way to show me the files I can delete the library because they are not used.  The thing is, I select this option, I see it shows me files that are certainly in use on the timeline, then what's the point of this?  How can I show actually files that are not used and as long as I can safely remove?

    It shows the unused portions of clips. If you want to remove a clip that has any items used in a project, you're better activation of the clipping indicator used. Any clip with an orange bar has been used.

  • Why my pictures not saved with the extension of jpeg file and how do I get back them without all these numbers that are displayed

    photos that I can see are marked differently as in this example

    3D 18805-DC2C-4AOF-B308-FESCCEC3A61

    Hello

    We would like to provide you with more information about the issue by answering the questions below:

    • What is the program you are using that allows you to see the name of the .jpeg files in

      3D 18805-DC2C-4AOF-B308-FESCCEC3A61?

    • What type of program you use in editing photos?
    • What are the steps you take in the mounting of the .jpeg images?

    Thank you!

  • How to identify the clips in the finder that are used in the scenario?

    Heya, this is my first post on this forum and a question ive been struggeling with during some time...

    I am trying to store my images and reduce the amount of HARD disk space old projects are taking place. I have a LOT of images I will ever use again saved in the folders I want to easily identify and get rid of. Is it possible in first pro to 'tag' files that were used in the Assembly or the project, and then I can just go and remove those who are not. Similar to the sequels feature that removes the unused clips in the project (although their leaves still on the disc).

    It also would make transcoding the right files much easier that I currently have to identify each of them individually using the show in finder option...

    help on this would be highly appreciated

    I use CS5 on macbook for editing images canon DSLR, is there more information you guys need?

    See you soon

    Rich

    In the project Panel, click the drop-down; It's the small pile o ' thing of pancakes in the upper right corner of the Panel. Select "display metadata." In the search box, type 'use' - this will reveal the labels of metadata using video and Audio. Check those to add and click OK. they will now be added to the columns in the project Panel. Now, you can sort on the filter columns used - unused clips will not have a number associated with this column. Select them all and if you really want to purge them of the drive, press Ctrl / Cmd + delete - that will remove the media from the drive.

    If you just want to get rid of the clips, project > remove unused will do.

  • I use Windows Vista and want to know if there is a way to show all programs, devices or equipment that are using my internet connection.

    original title: internet connections

    I use windows vista home premium II edition and I would like to know if it is possible to view each program, material, device, etc., which is connected to the internet at the same time on my pc and I can vew all in the same window screen?

    Hello nephew0117,

    Unfortunately, there is no tool that would give you a report on what programs are using Internet connection on your computer.

    None of the devices use the Internet connection on the computer if you connect external devices.

    You can check the task manager that will give you information about what programs are running and you can check what programs use the Internet.

    You can also look for some third-party programs that will help you monitor it. You can use your favorite search engine to find it.

    DISCLAIMER OF THIRD PARTY SOFTWARE:

    Using third-party software, including hardware drivers can cause serious problems that may prevent your computer from starting properly. Microsoft cannot guarantee that problems resulting from the use of third-party software can be solved. Software using third party is at your own risk.

  • How can I add titles and ALT text to Images that are used as fill?

    I built a site and in most cases, all images are fillings.  I want to update the title and the replacement text, but do not have the option.  It seems that I can only do this to images that have been placed?  If this is the case - how to place an image on an area I want to be filled.

    Thank you

    The work around you are use is probably the best solution because there is no way to add the alt text of an image placed in a frame.

  • Could not enumerate the virtual machines that are used as models

    Hey guys,.

    I have a simple script that collects information from a virtual computer. Unfortunately, I'm getting a lot of mistakes, he doesn't pull out information if the virtual machine is used as a model.

    $date = get-Date-format-M - d - yyyy

    Import-Csv C:\test\servers_mate.csv - UseCulture | %{

    Get-VM-name $_. Name |

    Select Name,

    @{N = 'Center'; E = {Get-Datacenter - VM $_______ |} {{Select - ExpandProperty name}}.

    @{N = "Cluster"; E = {Get-Cluster - VM $_______ |} {{Select - ExpandProperty name}}.

    Host, NumCpu, MemoryGB,

    ProvisionedSpaceGB, Powerstate,

    @{N = "Path"; E = {}

    $current = get-view $_. ExtensionData.Parent

    $path = $_. Name

    {}

    $parent = $current

    if($parent.) Name - only "vm") {$path = $parent. {Name + "\" + $path}

    $current is get-view $current. Parent

    } While ($current. Parent - no $null)

    [channel]: join ('-',($path.)) Split('\') [0.. ($path). Split('\'). (Count-2)]))

    }},

    FolderId,

    @{N = "Manufacturer"; E = {(Get-VMHost-Name $_.)} Host). Manufacturer reference}},

    @{N = ' model'; E = {(Get-VMHost-Name $_.)} Host). Model}},

    @{N = "ProcessorType"; E = {(Get-VMHost-Name $_.)} Host). ProcessorType}}

    } | Export-Csv "C:\test\servers-vcenter-servers-vmpath-$date.csv" - NoTypeInformation - UseCulture

    the output current is like that.

    NameData CenterClusterHostNumCpuMemoryGBProvisionedSpaceGBPowerStateFolder pathFolderIdManufacturerModelProcessorType

    I just also want to collect the same information, even if the virtual machine is used as a model. Introduction 1 additional column is perhaps something like below. So we can clearly identify if it is a virtual machine or be used as a model? Thank you.

    NameData CenterClusterHostNumCpuMemoryGBProvisionedSpaceGBPowerStateFolder pathFolderIdManufacturerModelType of processorVirtual MACHINE or template

    Erros I receive.

    Get - VM: get-VM VM with name 03/08/2015-12:40:44

    "xxxx" was not using the specified

    filter (s).

    Online: 2 char: 5

    + Get-VM-name $_. Name |

    +     ~~~~~~~~~~~~~~~~~~~~

    + CategoryInfo: ObjectNotFound: (:)) [Get - VM], VimException)

    + FullyQualifiedErrorId: Core_OutputHelper_WriteNotFoundError, VMware.VimA

    utomation.ViCore.Cmdlets.Commands.GetVM

    Try something like this

    Import-Csv C:\test\servers_mate.csv - UseCulture | %{

    Notice-EEG - ViewType VirtualMachine-filter @{'Name' = $_.} Name} | %{

    $esx = get-view-Id $_. Runtime.Host

    $_ | Select Name,

    @{N = 'Template'; E={$_. Config.Template}},

    @{N = 'Center'; E = {Get-Datacenter - VM $_.} Name | {{Select - ExpandProperty name}}.

    @{N = "Cluster"; E = {Get-Cluster - VM $_.} Name | {{Select - ExpandProperty name}}.

    @{N = 'Host'; E = {$esx. Name}},

    @{N = "NumCpu"; E={$_. Config.Hardware.NumCpu}},

    @{N = "MemoryGB"; E = {[int]($_.)} Config.Hardware.MemoryMB/1KB)}}.

    @{N = "ProvisionedSpaceGB"; E = {($_.Summary.Storage.Committed+$_.Summary.Storage.Uncommitted)/1 GB)}},

    @{N = "Powerstate"; E={$_. Runtime.PowerState}},

    @{N = "Path"; E = {}

    $current = get-view-Id $_. Parent

    $path = $_. Name

    {}

    $parent = $current

    if($parent.) Name - only "vm") {$path = $parent. {Name + "\" + $path}

    $current is get-view $current. Parent

    } While ($current. Parent - no $null)

    [channel]: join ('-',($path.)) Split('\') [0.. ($path). Split('\'). (Count-2)]))

    }},

    @{N = "FolderId"; E={$_. Parent.ToString ()}}.

    @{N = "Manufacturer"; E = {$esx. Hardware.SystemInfo.Vendor}},

    @{N = ' model'; E = {$esx. Hardware.SystemInfo.Model}},

    @{N = "ProcessorType"; E = {$esx. Hardware.CpuPkg [0]. Description}}

    }

    }

    The error you see seems to indicate that there is an entry in the CSV file for a nonexistent VM.

  • We need to change the files that are used by some processes Opatch

    Hi all

    I apply the Patch.500 (Patch No.: 17529887) at our EMP 11.1.2.3 environment however I get error when I try to apply the Patch below.  I stopped all services of Hyperion before applying the patch. I also rebooted the server, once but always get the same error.

    Can someone help me please.

    Kind regards

    VJ

    So my only option would be Weblog Admin Server that all your services look at orders. Stop, disconnect you and login and try again.

    I don't know that should have checked the the Task Manager for active processes.

    Thank you

    Anjum

  • Script to get multimedia files that are used in the sequence active

    I have a script which replaces all the media in a project, which is great. Except when you have 600 movie files to cross!  I would like to provide the user the ability to simply replace the film used in the active sequence, but I can't figure out how to get the names of the files associated with the clips in a sequence.

    The closest I got music videos is "app.project.activeSequence.videoTracks". I used the Explorer object and function from the PProPanel example getProps and getMethods, and I can't find a way to the media for a sequence file info.

    Thanks for your time!

    You can export FCP XML and parse the clips used from there.

  • How to find the tables that are used in a procedure

    Hello
    I need to write a SQL to find (user_source) procedures or triggers (from user_triggers), whose code contains the registerd tables in a table X.
    In other words, I have a table X with files having a column containing tables. I want to write a SQL to obtain these (proc, package and triggers) container objects or use the tables inside
    Can you help me?
    Thank you!

    Mark1970 wrote:
    Hello
    I need to write a SQL to find (user_source) procedures or triggers (from user_triggers), whose code contains the registerd tables in a table X.
    In other words, I have a table X with files having a column containing tables. I want to write a SQL to obtain these (proc, package and triggers) container objects or use the tables inside
    Can you help me?
    Thank you!

    I don't know if I understand your problem, but have you had a glance at the data dictionary views USER_DEPENDENCIES or ALL_DEPENDENCIES?

    It has classified hard dependencies of objects.
    If a table is used directly (not in dynamic SQL code in a string) in an object PL/SQL, the dependency is available in the stated points of view.

  • How to multiply really small numbers that are commensurate with 10 ^-4

    My program requires me to read some values of Excel cells, which she does, and multiply with each other.  Unfortunately, when I read of the cell and convert it to digital, it rounds to zero because it's a very small number as 3.86 * 10 ^-4.  I don't want to do this. How would it stop happenning.

    • How do you get data from excel?
    • How do you convert to numeric values? What do you use to convert?  (for example you must use "fractional chain to the number" instead of 'decimal string to the number')?
    • What is the data type of the result? (Make sure that it is orange and not blue).
    • What is the display format of the indicator?

Maybe you are looking for

  • How to stop reducing the size to straighten photos?

    Opening has been really great for the recovery of the photos. I understand how to do this in pictures, but my problem is it strongly seems to reduce the size of the photo. Opening did not do that; It simply reduced all that has been cropped in smooth

  • Time Machine impossible to restore backups

    Hello I had to restore my entire machine (because I am stupid) and when I went to access my Visual readers of Parallels, missing 2. It seems they were always absent (I went back I can. I'm not saying TM to ignore readers, and I see no reason why they

  • Triggered recording

    Hey everybody, I have a particular problem regarding the logging of data after a certain trigger condition has been met. My task is to save some data based on a particular trigger condition, data to be connected must be previous data (e.g. 1 sec prio

  • Why is my Dell 720 printer does not print anything? Help me please!

    OK, so I'm trying to print basically nothing of importance, but when I click on the Fax icon, it turns the paper into the printer as if it were actually print something, but I only have a blank sheet of paper. Why? I'm not this computer. any help wou

  • 4.0.4 mini Pro - cannot click on contacts

    I installed my Mini Pro 4.0.4 and noticed that I was not able to click on contacts.  When I tapped on a touch, nothing happens.  I then 'fixed' the phone, and then I was able to draw on contacts.  However, some time in the last 24 hours, the problem