Interesting question of sql

Hi all

Suppose I have the table and the output as below.

9

10

24

25

39

40

41

55

56

57

71

72

86

87

88

102

103

104

118

119

I would like to mark the sequential lines. For example, insert a new column, and the value of an id of the line 9 and 10 column is 1. For the 24 and 25 2, etc.

Use windowing functions?

Thank you

with qry (val) as long as)

Select 9 Union double all the

Select 10 of all the double union

Select 24 in union double all the

Select 25 in union double all the

Select 39 Union double all the

Select 40 Union double all the

Select 41 Union double all the

Select 55 in union double all the

Select 56 Union double all the

Select 57 Union double all the

Select 71 Union double all the

Select 72 Union double all the

Select 86 Union double all the

Select 87 in union double all the

Select 88 in union double all the

Select 102 Union double all the

Select union 103 double all the

Select union 104 double all the

Select 118 Union double all the

Select double 119

)

Select val, dense_rank() over (order by grp) grp_id

de)

Select the val

, val - row_number () (order by val) as grp

of qry)

order by val

VAL GRP_ID
9 1
10 1
24 2
25 2
39 3
40 3
41 3
55 4
56 4
57 4
71 5
72 5
86 6
87 6
88 6
102 7
103 7
104 7
118 8
119 8

Tags: Database

Similar Questions

  • Interesting question of sql 2

    Hi all

    I want to compare the data of the current column to another column of data, but for all values.

    Version: 11g

    with

    a as (

    Select 1 col1, 5 col2 from dual

    Union all

    Select 2, 10 from dual

    Union all

    Select 3, 15 from dual

    Union all

    Select 4, 20 from dual

    Union all

    Select 5, 25 from dual

    Union all

    Select 6, 30 from dual

    Union all

    Select 7, 35 from dual

    Union all

    Select 8, 40 from dual

    Union all

    Select 9, 45 from dual

    Union all

    Select 10, 50 from dual

    Select * from a;

    For example, I want to compare for each given col2 to all data in col1. I want to create a new column and if col1 contains 5 then he should write Yes, another no. If col1 contains 10 then yes other no. So for the example above, the output should be as below.

    1    5   Yes

    2    10   Yes

    3    15   No

    4    20   No

    5    25   No

    6    30   No

    7    35   No

    8    40   No

    9    45   No

    10    50   No

    Thank you

    Hello

    I suggest EXISTS, as Rahul showed in response #7.  To get the exact results you requested, use it like this:

    SELECT a.*

    CASE

    WHEN THERE IS)

    SELECT 1

    Of an a2

    WHERE a2.col1 = a.col2

    )

    THEN '' Yes. ''

    ANOTHER 'no '.

    Flag of the END as the

    A

    ORDER BY col1

    ;

    You can use a subquery IN rather than an EXISTS subquery, like this:

    SELECT a.*

    CASE

    WHEN IN col2 ( )

    SELECT col1

    A

    )

    THEN '' Yes. ''

    ANOTHER 'no '.

    Flag of the END as the

    A

    ORDER BY col1

    ;

    An outer join, as suggested in the response to #4, Nimish is good, too, but if col1 is not unique, you may need to use SELECT DISTINCT (depending on your needs) which will be ineffective.  Solutions using the set operators UNION or LESS will be as ineffective.

    3018678 wrote:

    Is there a solution with the analytical functions windowing or something like that?

    Yes, but it's inefficient and complex.  If you really want to try this, see:Re: getting the value of a column based on another column

    Why do you want to use an analytical function?   What is the problem with solutions already posted?

  • How can I vote for an interesting question on the dedicated forum?

    Hello

    I know that Muse is a brand new application, but there are several relevant question - in my opinion - that should be considered first.

    After much navigation (!), I found a forum where you can vote for these interesting questions users have faced.

    Unfortunately, I'm unable to vote for one of theses messages if I am connected.

    Is there something to do to get this "right to vote"?

    I really want to participate in this improvement, just gimme the tools to do!

    Thanks for your response

    We know a few emails as of late in the ideas of the forums section and thus our Admin had turned off their.

    I have re-enabled them so you can vote and add ideas and apologize for the inconvenience.

    -j

  • New to Oracle - interested in certification SQL

    I am new to Oracle and am interested to learn SQL, but have to pay myself, seeks to do this through Oracle books.

    Have you noticed that there is a review called Oracle SQL Fundamentals I, who has his own book: [http://www.amazon.co.uk/gp/product/0071597867/ref=s9_sima_gw_s0_p14_t1?pf_rd_m=A3P5ROKL5A1OLE & pf_rd_s = center-1 & pf_rd_r = 0NNERWYN8T9PAX64B5HG & pf_rd_t = 101 & pf_rd_p = 467198433 & pf_rd_i = 468294]

    However, it doesn't seem to be a book for Oracle SQL Fundamentals II, although I saw somewhere that it will be published before the end of the year?

    This book seems to cover everything, but is for 9i: [http://www.amazon.com/OCP-Introduction-Oracle9i-Exam-Guide/dp/0072195371]

    Just a few basics:

    Which is the best db Oracle. Download for Windows XP that I can put on more than one computer, it is better for my sql certification?

    Can I take the exam SQL 9i or it is no longer used (can't seem to download from anywhere?)

    Can I take the exam at the Oracle headquarters or an authorized service center, without their own path?

    Thank you very much

    user11935518 wrote:
    I am new to Oracle and am interested to learn SQL, but have to pay myself, seeks to do this through Oracle books.

    Have you noticed that there is a review called Oracle SQL Fundamentals I, who has his own book: [http://www.amazon.co.uk/gp/product/0071597867/ref=s9_sima_gw_s0_p14_t1?pf_rd_m=A3P5ROKL5A1OLE&pf_rd_s=center-1&pf_rd_r=0NNERWYN8T9PAX64B5HG&pf_rd_t=101&pf_rd_p=467198433&pf_rd_i=468294]

    The book is related to the exam 1z0-051. I'm not sure it's the best way to learn SQL from scratch. However, since once you know a little SQL book is useful, though sometimes, some might say t make sure that you get enough practice.

    However, it doesn't seem to be a book for Oracle SQL Fundamentals II, although I saw somewhere that it will be published before the end of the year?

    Don't worry in the short term. There is a review of SQL, you may want to consider longer term (1z0-047), but which is advanced. ISBN-13: 978 - 0071498500 probably apply the material (but does not focus on the review... maybe it's a good thing).

    This book seems to cover everything, but is for 9i: [http://www.amazon.com/OCP-Introduction-Oracle9i-Exam-Guide/dp/0072195371]

    Just a few basics:

    Which is the best db Oracle. Download for Windows XP that I can put on more than one computer, it is better for my sql certification?

    Oracle is resource intensive; and more as it increases version numbers.

    10g XE [http://www.oracle.com/technology/products/database/xe/index.html] is perfect, EXCEPT that it is 10g 11g not and cannot indicate features of 11g but its greate from the manageability perspective.

    11 GR 1 material has a much higher footprint, but course has all the features.

    Unfortunately, it's a choice s one or the other. and historically the windows uninstaller can be an ightmare.

    I think that I must really be suggesting you look at virtualization - example: [http://www.virtualbox.org/] to run Oracle 10 g XE at first... but then again I am not sure if I'm over complicating things and have not tried it myself.

    Versions of the database newever and reviews using the SQL syntax that is no longer compatible with ansi standards more late especially in the use of the joins of tables in my humble OPINION.

    Can I take the exam SQL 9i or it is no longer used (can't seem to download from anywhere?)

    You can take the exam but its is no longer available for download. REF for example unable to download Oracle 9i database (any version)

    Can I take the exam at the Oracle headquarters or an authorized service center, without their own path?

    You can take in some centres of Pearson VIEW [http://pearsonvue.com/oracle/locate]. (1z0-051 can also be taken online).

    Thank you very much

    If you want some tutorials to practice simple SQL online be sure to visit [www.w3schools.org] but attention to other SQL dialects. This site is safe certification, but there are many who are not. See [http://forums.oracle.com/forums/ann.jspa?annID=1122] and other messages of the forum announcement.

    Visit also [http://www.oracle.com/education/certification]

    Published by: bigdelboy on 24-Sep-2009 04:30

    * I just remembered - a caveat: Please note Oracle requires professional XP (XP Home and Vista Home does not work... If you have these virtualbox perhaps with linux work and stay within the license agreement *.

  • Question of SQL monitoring control 12.1.0.4 clouds

    All the

    I used 12.1.0.2 EM cloud control for awhile and since the run to monitor SQL screen I have had direct access to bind variables in the SQL statement monitored.

    before_Screenie.jpg

    This feature doesn't seem to be available in 12.1.0.4, or, if this is the case, it seems to be very hidden...

    Clues on where I can easily find this information from within the EM CC on 12.1.0.4?

    We have an answer!

    In the main, (followed by executions SQL) view SQL monitor locate the SQLID you are interested and make your cursor the status"" column.  Click on the status icon-

    This will bring you down to the detail of SQL executions and to the right you will see the "View report" button that is not monitored in the other view.  Click on it and you have your information variable bind in the report.

    Thank you!

    Micheline

  • IAAS configuration question - database SQL

    I have questions, get the IaaS of vRA setup part.  When installing, I get an error message saying 'domain user iwic\vra.svc is invalid or the database to access denied.  Validation error 1385. "This has occurred trying to connect to a SQL cluster and with a local installation of SQL on the server of IaaS.  I excluded the problems of firewall, ensure that the vra.svc has full right to SQL server, verified password admin and correct username.  At this point, I'm stuck and looking for help on getting this Setup is complete.

    install error.tiff

    The issue ended up being with the port number of the SQL instance.  The port number for this instance of SQL changed and I do not have this information.  When I was with SQL Management Studio to connect to SQL server, it requires a port number during installation of vRA you must know the correct port of the SQL cluster number.

  • question about SQL and VMDK places

    Hello world. Im kinda new here so please be gentle

    I'm confused on the locations of the files for sql.

    At this moment I have 1 with 3 vmdk files sql server executes a muscular 100 GB sql database.

    My disks are as follows

    1 OPERATING SYSTEM

    2 DB

    3 newspapers

    They are all thick and they are all stored with the virtual machine in the virtual machine configuration.

    It lies in a cluster HA/DRS and we use them both.

    The question boils down to performance.

    If my VM is stored on DATASTORE_A and the VM folder on this data store has all the VMDK files in it, it would be safe to say that they are all on the same disk as much as vsphere is concerned.

    Now to get best performance, I want to separate my VMDK files to separate data (with faster operation) warehouses to avoid conflicts of drive on my current data store. What is the right way to go about this?

    How separate you your VMDK to other data warehouses, and enjoy other performance data store? WE do not use DTS at all so im sure it although we use HA/DRS in our group... and yet, I don't think that it is important in this case... just more of an FYI.

    What do you do to get your SQL servers to run in vmware?

    Seems like a basic question.

    The answer seems easy. Separate disks so that they do not fight.

    'S virtually done it with VMDK but the data store underlying is 1 speed and they all exist on this subject, so... How to separate them at that level for best performance?

    Also... once I keep them separated, how can I keep my sanity by knowing my VMDK are not with the virtual machine? This kind of made a mess . Of course the performance takes a front seat for my mental health.

    Thank you all

    1. If I sVmotion my other vmdk files via the advanced options of one in another data store, it will create the files folder structure based on my VM name and place the vmdk inside?  (I guess I could just test it and see).

    Yes, the VM configuration file (.) VMX) will be modified to point to the new location of the virtual disk. You can use the virtual machine property editor to check for this, once the Storage vMotion.

    2. with regard to the disk controller, I assume you mean a virtual controller by VMDK in the vmx / correct the settings of the virtual machine and not a phyical on the hardware controller? (IM pretty sure I know the answer here but I just want to be clear).

    Yes, the virtual controller is correct.

    If so, what type of controller? LSI Logic or it would benefit all a paravirtual adapter?

    As long as your operating system is supported, go with the PVSCSI every time - especially for newspapers and the controller file data.

  • General question about sql DB to vcenter

    Basically, we need to know how many connections SQL DB to go from one instance of vCenter 5?

    It is dependent on host?

    It is dependent on comments?

    Is there a way we can we estimate how many connections?

    DBA SQL told us we have currently a large number of connections, but we do not think that this could be cauisng questions.

    vCenter uses a connection pool (10 by default as he answered already). This is usually done by web application to manage db connections required by multiple login sessions (no need to reopen a db for each session connection... open a db connection sometimes takes more time that select it dumb that they do).

  • Question about SQL * connect more in the syntax

    Good evening

    I can connect successfully from the client to the host using the following command:
    0 19:40 [Oracle] [23G] [569M] E:\Client>sqlplus scott/abc123@dbca
    
    SQL*Plus: Release 11.2.0.1.0 Production on Sun Aug 22 20:01:56 2010
    But I wanted to omit the password, so I tried:
    0 20:03 [Oracle] [23G] [590M] E:\Client>sqlplus scott/@dbca
    thinking that SQL * more tempt me the password but, if it does at all. I tried in vain a few variations. I read the specifications of command line for SQL * more and it seems that this command should work.

    Questions: What is the problem with the command I typed and what is the correct syntax?

    Thank you for your help,

    John.

    To omit the password using connect scott@dbca , but do not connect scott/@dbca of sqlplus.
    or sqlplus scott@dbca

  • Question of SQL statement

    I have this PreExpression at a stage of SQL statement:

    Locals.SQL_LatestResult = "SELECT UUT_RESULT.ID, UUT_RESULT. UUT_SERIAL_NUMBER, UUT_RESULT. START_DATE_TIME UUT_RESULT WHERE (((UUT_RESULT. UUT_SERIAL_NUMBER) =------"' + Locals.serial + ' \ ') AND ((UUT_RESULT." START_DATE_TIME) = (SELECT MAX (UUT_RESULT2. START_DATE_TIME) OF UUT_RESULT AS UUT_RESULT2 WHERE UUT_RESULT. UUT_SERIAL_NUMBER = UUT_RESULT2. UUT_SERIAL_NUMBER))); »

    Locals.SQL_LatestResult has this value after the PreExpression:

    SELECT UUT_RESULT.ID, UUT_RESULT. UUT_SERIAL_NUMBER, UUT_RESULT. START_DATE_TIME UUT_RESULT WHERE (((UUT_RESULT. UUT_SERIAL_NUMBER) = "15514011") AND ((UUT_RESULT. START_DATE_TIME) = (SELECT MAX (UUT_RESULT2. START_DATE_TIME) OF UUT_RESULT AS UUT_RESULT2 WHERE UUT_RESULT. UUT_SERIAL_NUMBER = UUT_RESULT2. UUT_SERIAL_NUMBER)));

    I get the number of records = 0, if I run the sequence.

    If I copy the exact same SQL query in access I get what I want to know a record.

    If I remove that part of the query:

    ((UUT_RESULT. UUT_SERIAL_NUMBER) =------"" + Locals.serial + "\") "

    I get 388 records which is correct and it run directly in access.

    What's not here?

    I was too fast for this post... it's my fault, the database link was wrong, so data were there...

    Statements are very good!

  • Question about SQL server 2008

    I can't remove the Default constraint in Management Studio. But in the query, I can drop Default constraint

    For assistance please ask for help in the appropriate Microsoft TechNet SQL Server Forums

    Thank you & good luck.

  • Two questions: Running XP and have some interesting questions at the start and with IE.

    Hi, I try to wear the IT hat and works to clear up some questions on my mother's computer.  #1 I guess that the computer was shipped with a version of Corel Photo software on it and we cannot get rid "Installer" messages at the beginning upward.  We tried to remove the program and the same message comes back to tell us that "Installer can do the requested action without the CD/program files" it gets about 6 of these reviews that it must close any until the computer will continue to boot the system.  Please, please tell me how to get rid of this.  I tried to install the 'Installer' update to see if that would make the difference and nope.  I also tried to remove the Corel file via CCleaner and got the same message.  I do not have the program disc, I don't want to program... I want to just get rid of it!

    #2 when entering address in the Internet Explorer address bar, the browser opens a second browser instead of going to the requested site.  For example, when I open my Internet Explorer and say go to the top of the address bar and typewww.google.com, instead of going to Google, it opens a completely separate browser.  When she did this, it's EXTREMELY SLOW!  until you think that IE went unresponsive and then finally opens the second browser.

    I'd appreciate any help!  I'm trying to solve these problems, while I'll be staying here so that I can leave him a computer running.

    Thank you!

    Hello

    ·        What version of Internet explorer that you are using (Internet Explorer 6, 7 or 8)?

    ·        Was long before Internet Explorer work?

    ·        Since when are you facing this problem?

    Step 1:

    It may be some third-party software that runs in the background that is shown with the process, I suggest you do a clean boot and check. To perform a clean boot follow the steps mentioned in the link given below.

    How to configure Windows XP to start in a "clean boot" State

    http://support.Microsoft.com/kb/310353

    Note: Once you have finished installing, follow step 7 to start the computer in normal startup.

    If the steps above don't help you not to remove the Corel Photo software, I suggest you to post your query on the forums of XP. Click on the link below.

    http://social.answers.Microsoft.com/forums/en-us/xpprograms/threads?filter=answered

    For Internet Explorer related issues, follow steps 2 and 3 of the step.

    Step 2:

    I suggest you run the fix it this tin article given to repair Internet explore

    How to reinstall or repair Internet Explorer in Windows Vista and Windows XP

    http://support.Microsoft.com/kb/318378

    Step 3:

    If you use Internet Explorer 7 or 8 I suggest you run the fix it is present in the article below. If you use Internet Explorer 6, you can follow the steps mentioned in the article given below where they apply to Internet Explorer 6 also.

    How to reset Internet Explorer settings

    http://support.Microsoft.com/kb/923737

    Thanks and regards.

    Thahaseena M
    Microsoft Answers Support Engineer.
    Visit our Microsoft answers feedback Forum and let us know what you think.

  • BlackBerry Z10 stupid but very interesting question on your blackberry microphone remote

    Hello

    I have a question that I now have a fight with 10 friends around a table.

    There is a rumor in my country that your cell phone can be heard even when you talk, when he's just sitting idle in stand-by but turned on. As a person can open your microphone from far away and listen to whatever it is you're talking to the table.

    My question is, is it possible? How is it possible?

    Having been to many of the foundries around the world, I can say that it is feasible as possible but almost certainly not practical.  He needs collusion on a scale from Golden to be implemented.

    Any suspicion of a phone, this would result in it being gutted, the tops taken out of the chips, and probes introduced by expert monitoring and chip design.

    What is possible, it is for your position to be checked by means of a phone and a phone to be cloned and calls intercepted. If you talk on the phone, the call can also be intercepted at the end of service provider and to recent leaks, it is a certainty that the Governments that, with the United States it seems to be one of the worst (or best) with a massive mainframes, passing to sift through all the calls of keywords to trigger.

    Unfortunately, it's the world we live in now.

    Hope, your dinner party went well and that you kept your dinner talk about hazardous materials.

  • Interesting question of scrolling

    Hi everyone, I have a problem with scrolling in my area

    The page layout, I currently have is:

           vfm0 = new VerticalFieldManager(USE_ALL_WIDTH | USE_ALL_HEIGHT | NO_VERTICAL_SCROLL | NO_VERTICAL_SCROLLBAR);
            add(vfm0);
    
            vfm1 = new VerticalFieldManager(USE_ALL_WIDTH | VERTICAL_SCROLL | VERTICAL_SCROLLBAR);
            vfm0.add(vfm1);
    

    and I add a created custom field to vfm1.

    However, every time I scroll the focus passes power to another, but the screen does not scroll down UNTIL the last field wins the update. Once the last field acquired focus, scrolling further causes the screen to scroll down.

    I tried to add simple labelfields at the vfm1 and it scrolls perfectly but created custom fields are causing the problem.

    Can anyone think of what may cause this effect?

    In the custom field is created, I replace the onFocus() and the onUnfocus() but I do not see why this would have caused this problem.

    I found the problematic code.

    So the custom field I have added is horizontalFieldManager and inside, I bitmapfield

    Now, in the horizontalFieldManager I crushed focus... that makes no sense since fieldmanagers don't really get the focus (as in the past, I read in this forum).

    At the same time, I was the substitution of development for the bitmapfield as well.

    Question/bizarre and illogical behavior...

  • interesting question of the vpn site to site NAT/PAT traffic config

    I have an ASA 8.4.2 running code and am just checking the Site to site configs before migration of tunnel. more precisely if the NAT/PAT and ACL is correct. Phase 1 is already defined and work, as well as cryptographic maps and tunnel groups.

    When you set the traffic interesting in the ACL are you using NAT or the real IP? The order of the ACL is correct?

    First of all:

    The vedor network is a 192.168.1.10 and must be coordinated to 10.1.0.2

    name 5.6.7.8 VendorName object-group network VendorName-R network-object host 192.168.1.10 object-group network VendorName-NAT-R network-object host 10.1.0.2 object-group network VendorName-L network-object host 10.1.1.3 access-list VendorName-crypto extended permit ip object-group VendorName-L object-group VendorName-NAT-R nat (inside,outside) 1 source static VendorName-L VendorName-NAT-R destination static VendorName-R VendorName-R

    Second:

    Sellers network is 192.168.1.0 to 192.168.2.0, these must be PATed 10.1.0.2 and 10.1.0.3

    192.168.1.20 and 168.1.21 must be staticly using a NAT 10.1.0.4 and 10.1.0.5

    Name the SupplierName 5.6.7.8

    object-group network VendorName-R-1

    network-object subnet 192.168.1.0 255.255.255.0

    object-group network VendorName-R-2

    network-object subnet 192.168.2.0 255.255.255.0

    object-group network VendorName-R-3

    network-object host 192.168.1.20

    object-group network VendorName-R-4

    network-object host 192.168.1.21

    object-group network VendorName-NAT-R-1

    network-object host 10.1.0.2

    object-group network VendorName-NAT-R-2

    network-object host 10.1.0.3

    object-group network VendorName-NAT-R-3

    network-object host 10.1.0.4

    object-group network VendorName-NAT-R-4

    network-object host 10.1.0.5

    object-group network VendorName-R

    network-object VendorName-NAT-R-1

    network-object VendorName-NAT-R-2

    network-object VendorName-NAT-R-3

    network-object VendorName-NAT-R-4

    object-group network VendorName-L

    network-object host 10.1.1.3

    the object-Network 10.1.1.6 host

    VendorName-crypto allowed extended ip access-list object-VendorName-L Group VendorName-R

    NAT (inside, outside) 1 dynamic source VendorName-l VendorName-NAT-R-1 static destination VendorName-R-1 VendorName-R-1

    NAT (inside, outside) 1 dynamic source VendorName-l VendorName-NAT-R-2 static destination VendorName-R-2 VendorName-R-2

    NAT (inside, outside) 1 static source VendorName-l VendorName-NAT-R-3 of destination VendorName-R-3 static VendorName-R-3

    NAT (inside, outside) 1 static source VendorName-l VendorName-NAT-R-4 static destination VendorName-R-4 VendorName-R-4

    Your valuable traffic acl MUST be the IP NAT address.

Maybe you are looking for

  • Headphones are covered by the warranty?

    I bought a pair of Apple headphones in a third party mobile phone store. These headphones have a 1 year warranty? I do not have the receipt so I don't know if it matters?

  • Last updated for IOS 9.2, iCould Backup no longer works. Help, please!

    Recently updated for IOS 9.2, now my iCould plu backup works. Help, please! I desperately need free up space on my phone.  I click 'NTI Backup Now' and after 10 minutes of inactivity, I get a message enter my login iCould on my phone, (is the correct

  • XY graphics memory model

    I found a need for a XY chart in one of my apps, and I'm trying to wrap my head around how to use it properly. My implementation looks like this: That is closely modeled after one found here: http://digital.ni.com/public.nsf/allkb/18B56D8556D44BF1862

  • How to keep the menu to appear when a button is selected?

    It's driving me crazy, I have a button field that the user can select by clicking on the screen (storm) or by pressing the navigation button (other devices).  Whenever the use clicks the button, the application menu is displayed.  I have not yet defi

  • Game screen reduced in speakers playing a game

    During playback of an mmo with full screen suddenly the screen of the game minimizes and falls back to the taskbar. By clicking on the icon of the game brings back the screen full