SQL Number increment
I want a query that increment a number by one after each certain number of records...
example,
after 3 rows it increases a counter by 1
Counter Value
1 A
1 b
1 c
2 d
2 e
2 f
3 d
3 e
3 f
NTILE(3) will split all rows into three equal size (as close as possible) groups while OP asked to divide all rows into groups where each group has 3 rows. All you need for that is ROWNUM. See the difference:
SQL> select ename,NTILE(3) OVER(ORDER BY ename) from emp;
ENAME NTILE(3)OVER(ORDERBYENAME)
ADAMS 1
ALLEN 1
BLAKE 1
CLARK 1
FORD 1
JAMES 2
JONES 2
KING 2
MARTIN 2
MILLER 2
SCOTT 3
ENAME NTILE(3)OVER(ORDERBYENAME)
SMITH 3
TURNER 3
WARD 3
14 rows selected.
SQL> select ename,ceil(rownum / 3) from emp;
ENAME CEIL(ROWNUM/3)
MILLER 1
CLARK 1
KING 1
ADAMS 2
SMITH 2
JONES 2
FORD 3
SCOTT 3
JAMES 3
MARTIN 4
WARD 4
ENAME CEIL(ROWNUM/3)
ALLEN 4
BLAKE 5
TURNER 5
14 rows selected.
SQL> SY.
Similar Messages
-
Issue with Oracle.sql.NUMBER in Java Stored Procedure
When we try to make a call to the Oracle.sql.NUMBER(String) inside a java stored procedure and pass values from '01' to '09', it throws java.lang.StringIndexOutOfBoundsException: String index out of range: 3
We use Oracle 9.2.0.6 - JServer Release 9.2.0.6.0.
It works fine for other values. Please find below the code used for simulating the issue outside the application. Thanks.
create or replace and compile java source named testNumber as
import oracle.sql.NUMBER;
import java.sql.SQLException;
public class TestNumber
public static String convertNumber(String parm) {
NUMBER nTest;
try {
nTest = new NUMBER(parm);
return "TRUE";
}catch (SQLException sqle) {
return "FALSE";
create or replace function test_number (p_str in varchar2) return varchar2 as
language Java name 'TestNumber.convertNumber(java.lang.String) return
java.lang.String';
select test_number('05') from dual; - Throws exception ORA-29532: Java call terminated by uncaught Java exception: java.lang.StringIndexOutOfBoundsException: String index out of range: 3
select test_number('5') from dual; - Works fine
select test_number('010') from dual; - Works fineSiva,
I'm only guessing, but it could be an Oracle bug, in which case I suggest checking with Oracle Support.
(You do have a support contract, don't you? ;-)
Did you try compiling and running your java class "TestNumber" outside the database?
Class "oracle.sql.NUMBER" should be in Oracle's JDBC driver, I believe.
Good Luck,
Avi. -
Hello all,
Windows XP SP 3 32 bit
Java(TM) Platform 1.6.0_11
Oracle IDE 3.1.07.42
Versioning Support 3.1.07.42
Installed SQL Developer 3.1.07.42 in a fresh directory. Imported Connections from SQL Dev. 3.0. Connected to a 9i/11g-database and did a select on an ordinary table in the worksheet. Get an error in the Logging Page - Log Window:
Source: oracle.dbtools.raptor.controls.grid.ResultSetTableCellRenderer
Message: oracle.dbtools.raptor.controls.grid.ResultSetGridCell.computeDisplayValue(ResultSetGridCell.java:28)
All NUMBER-Fileds are displayed with "oracle.sql.NUMBER@...", for example "oracle.sql.NUMBER@lb5889c". And everytime i select a field in this table the Logging-Page grows (actually 3674 entries). And it's regardless which table i select. This error occurs also in the table-data-grid.
Can you help?
Thank you
MarkusHi Markus,
I usually download SQL Developer without the JDK, so I had to download sqldeveloper-3.1.07.42.zip to verify. Yes, in fact tzmappings and the zi are there, both when inspecting the archive and after performing unzip.
Something must have gone wrong with your download/unzip. Looking at various Java JDKs I have installed, or the Java that comes with Oracle 11.2.0.1, all have tzmappings and the zi directory. The file timestamps and the number of files in the zi directory may vary, but it should always be there in some form.
Regards,
Gary
SQL Developer Team -
How to display oracl.sql.NUMBER in the debugger?
Hi,
I would like to use oracle.sql.NUMBER for various reasons.
Unfortunately, I found no way to display in the JDev debugger
the actual VALUE that is represented by an oracle.sql.NUMBER object.
Is this really not possible or am I missing something here?
Thanks for any hints.
MarcelHi Steven,
I get the following warnings and errors if I use oracle.jbo.domain.Number
in a SQLJ-Class (using JDev 3.1.1.2):
Warning: (39) Invalid CustomDatum implementation in oracle.jbo.domain.Number:
missing the factory method getFactory.
Error: (39) Nicht unterst|tzter Java-Typ f|r Host-Element SeqNr (bei Position #1):
oracle.jbo.domain.Number..
Error: (66) Nicht unterst|tzter Java-Typ f|r Host-Element SeqNr (bei Position #1):
oracle.jbo.domain.Number..
I translate the last two error-messages to english:
Unsupported Java-type for host item SeqNr (at Position #1)
So now I am caught, I can't debug with oracle.sql.NUMBER, and I can't compile
with oracle.jbo.domain.Number.
Anyway, could you please convince the JDev-debugger team that the oracle.sql.NUMBER
needs to be displayed in the debugger as nice as its jbo twin. Without this
capability, this class is (at least for me) nearly useless.
Thank you for your support.
Marcel -
Tomcat: java.lang.NoClassDefFoundError: oracle/sql/NUMBER
hi,
i have managed to come this far with my "simple" webapplication under tomcat.
the exception is:
java.lang.NoClassDefFoundError: oracle/sql/NUMBER
since i have tried to put the classes12.jar in every reasonable directory without effect, i have to bother this forum. does anyone know "where the dog is burried"(german saying)?
greetz
Selim KeserHi yves,
This class is in the jdev_home/jdbc.lib/ojdbc14.jar.
But prior to deploying your ADF application, did you install the ADF runtime libraries to Tomact as explained here?:
http://www.oracle.com/webapps/online-help/jdeveloper/10.1.3?topic=j2ee_ptomcatdeploy_html
Thanks
Prasanth -
Sequence number - increment one for every 3 rows
Dear All,
I want to get a sequence number /group number, which increments 1 for every 3 rows.
For Example:
Seq Name
1 a
1 b
1 c
2 D
2 E
2 F
3 G
3 H
3 I
4 abc
4 aaa
4 bbb
Is there a function to do this?Please post DDL, so that people do not have to guess what the keys, constraints, Declarative Referential Integrity, data types, etc. in your schema are. Learn how to follow ISO-11179 data element naming conventions and formatting rules. Temporal data should
use ISO-8601 formats. Code should be in Standard SQL as much as possible and not local dialect.
This is minimal polite behavior on SQL forums. Did you read the header of this forum?? But besides being rude, you are also ignorant. A table has no ordering, so
there is no concept of every third row. What are you using for a sort key? What happens when a new row is added to or deleted from this table?
--CELKO-- Books in Celko Series for Morgan-Kaufmann Publishing: Analytics and OLAP in SQL / Data and Databases: Concepts in Practice Data / Measurements and Standards in SQL SQL for Smarties / SQL Programming Style / SQL Puzzles and Answers / Thinking
in Sets / Trees and Hierarchies in SQL -
DMS Version Number Increment Control
Dear Gurus,
I have to set a type document with increment version alphanumber so the version has to begin with A , B,...
so I have to set in Customizing '* ' in Vers,No.
Somebody knows which is the user exit to change increment version number of the DIR?
Thanks in advanceHi-
Assuming you are in ECC 6.0, You can find the BADI by going to SE18 and selecting the radio button "BADI name" and enter "DOCUMENT_NUMBER01" in the text box to right to see the definition.
The method is: DOCVERSION_CHECK
I hope it helps!
-J -
Quote number increment with macro button
Excel 2010 - I am using the following code to convert a worksheet quote to PDF and save to a specified file location.
Sub SavePDF()
ActiveSheet.ExportAsFixedFormat Type:=xlTypePDF, _
Filename:="C:\PDF\Quotation_" & _
ActiveSheet.Range("H8").Value & ".pdf", _
OpenAfterPublish:=False
End Sub
I would also like to have the quote number in cell H8 automatically increment every time this macro button is clicked. Can it be done.Try this - I hope yo see the changes that were required so that you can expand on it in the future:
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
'Sam, Pete, Joe, and a blank cell in a named range "NamesList"
'cycle values in cell range (F7:Q7,W7:AH7)
If Target.MergeCells Then
If Target.Cells.Count <> Range(Target.Address).Cells.Count Then Exit Sub
Else
If Target.Cells.Count > 1 Then Exit Sub
End If
If Not Intersect(Target, Range("F7:Q7,W7:AH7")) Is Nothing Then
Application.EnableEvents = False
If Target.Cells(1).Value = "" Then
Target.Cells(1).Value = Range("NamesList").Cells(1).Value
Else
Target.Cells(1).Value = Range("NamesList").Cells(Application.Match(Target.Cells(1).Value, Range("NamesList"),
False) + 1)
End If
Application.EnableEvents = True
Exit Sub
End If
If Not Intersect(Target, Range("B29:C29,B30:C30,B31:C31,B32:C32"))
Is Nothing Then
Application.EnableEvents = False
If Target.Cells(1).Value = "" Then
Target.Cells(1).Value = Range("TaskList").Cells(1).Value
Else
Target.Cells(1).Value = Range("TaskList").Cells(Application.Match(Target.Cells(1).Value, Range("TaskList"),
False) + 1)
End If
Application.EnableEvents = True
Exit Sub
End If
If Not Intersect(Target, Range("B17:C22, O17:P22, AA17:AB22")) Is Nothing Then 'specific range
If UCase(Target.Value) = "OK" Or UCase(Target.Value) = "FIX" Then MakeCircle Target
End If
End Sub -
Error in version number increment for version 99
Hi sap gurus,
I am getting the below issue that my document version number is from 00 to 99. Now we reached to 99. after this when we are trying to create a document with version 100, it is not allowing. how to resolve this situation. what s the way forward. please guide me.
Regards,
Mastan.Hi Mastan,
It is SAP standard. Use character with combination of number.
Like A0,A1......, B0,B1..... etc.
Surprised how you reached version 99 so fast in SAP.
Regards,
Krishnendu. -
Alphanumeric serial number increment
Hi All,
Can anyone help me to increment an alphanumeric sequence.
For eq: 12B345A, should become 12B345B,12B345C...,12B345Z after Z it should take the second last character and inceremnt it, say 12B346A,12B346B,12B346C.........
Please let me know whether we can use some Function Modules for this operation or can anyone please help me with a pseudocode for the same.
Thanks in Advance,
RijishTry this Code:
data: v_str(7) type c,
v_hx(1) type x,
v_len type i,
v_off type i.
field-symbols <fs>.
v_str = '12B345Z'.
write:/ 'Initial:', v_str.
v_len = strlen( v_str ).
v_off = v_len - 1.
do v_len times.
if v_str+v_off(1) between 'A' and 'Z'.
if v_str+v_off(1) lt 'Z'.
assign v_str+v_off(1) to <fs> casting type x.
add 1 to <fs>.
exit.
else.
v_str+v_off(1) = 'A'.
endif.
elseif v_str+v_off(1) between '0' and '9'.
if v_str+v_off(1) lt '9'.
v_str+v_off(1) = v_str+v_off(1) + 1.
exit.
else.
v_str+v_off(1) = '0'.
endif.
endif.
v_off = v_off - 1.
enddo.
write:/ 'Final:', v_str.
Regards
Sridhar -
I'm using Flash 8 -- Actionscript 2.0
I've created a quiz that i want to keep track of the user
score. i've created a function that, whenever the learner clicks to
check the answer of his/her question, checks the correct answer
versus what the person picked. I've created a function to play a
movie correct movie clip or incorrect movie clip depending on the
situation. i've also tried to add one to the user score each time
theperson is right, but so far, i'm only getting the first
addition, and nothing since (my trace result keeps coming back as
1...) can someone show me where i'm going wrong?Does the timeline have more than one frame, perhaps with a
gotoAndStop or gotoAndPlay back to this frame with this code. If
so, perhaps its resetting userScore back to zero each time that
happens.
e.g. if you have this on frame 1:
var userScore:Number;
userScore = 0;
trace(userScore)
userScore++
and this on frame 2:
gotoAndPlay(1)
then you will never see a trace of 1 because its being reset
to zero each time. -
Number increment in a row when a cell changes
Hi,
Here is my problem, I have a query giving me results like this, nothing special:
ASSEMBLY_LINE SERIAL_NUMBER OSSSHORTSEQ SEQUENCE COMP_NO....
LHEX BYP00128 L21 UF01
LHEX BYP00128 L21 UF01
LHEX BYP00128 L21 UF01
LHEX BYP00125 L21 UF02
LHEX BYP00125 L21 UF04
LHEX KFX00243 L29 FP01
LHEX PAS00343 W23 FP02
LHEX PAS00343 W23 UF03
resulting from this query:
SELECT *
FROM (SELECT locations_pkg.get_name
(locations_xtd_pkg.get_parent (agm_loc_id, 'Z')
) AS assembly_line,
act_px_pkg.get_string
(mfg_global_vw.agm_id,
act_px_types_pkg.f_mfg_if_serial_number
) serial_number,
workorder_tk_pkg.get_oss_short_sequence
(mfg_global_vw.agm_id)
ossshortseq,
components_vw.SEQUENCE, comp_no
FROM mfg_detail_vw vv,
mfg_global_vw,
mfg_supply_vw,
components_vw,
act_px
WHERE mfg_global_vw.agm_id = vv.agm_id
AND mfg_supply_vw.adm_id = vv.adm_id
AND ads_git_id = components_vw.git_id
AND mfg_global_vw.agm_status_id IN (1, 3, 7, 6, 4, 5)
AND mfg_global_vw.agm_asqt_nr IN (40, 50)
AND agm_loc_id = 99585
AND mfg_supply_vw.ads_id = act_px.act_id
AND act_px.actpxt_nr = act_px_types_pkg.f_lbdm_info)
GROUP BY assembly_line, serial_number, ossshortseq, comp_no, SEQUENCE
order by serial_number
I'd like now, to add a number, which would be the same for each line which have the same value of serial_number:
*ASSEMBLY_LINE SERIAL_NUMBER OSSSHORTSEQ SEQUENCE NUMBER COMP_NO....*
LHEX BYP00128 L21 UF01 1
LHEX BYP00128 L21 UF01 1
LHEX BYP00128 L21 UF01 1
LHEX BYP00125 L21 UF02 2
LHEX BYP00125 L21 UF04 2
LHEX KFX00243 L29 FP01 3
LHEX PAS00343 W23 FP02 4
LHEX PAS00343 W23 UF03 4
Any idea how I could do that?
Best regards!
Edited by: lakers on Apr 13, 2012 6:58 AM
Edited by: lakers on Apr 13, 2012 6:59 AM>
>
*ASSEMBLY_LINE SERIAL_NUMBER OSSSHORTSEQ SEQUENCE NUMBER COMP_NO....*
LHEX BYP00128 L21 UF01 1
LHEX BYP00128 L21 UF01 1
LHEX BYP00128 L21 UF01 1
LHEX BYP00125 L21 UF02 2
LHEX BYP00125 L21 UF04 2
LHEX KFX00243 L29 FP01 3
LHEX PAS00343 W23 FP02 4
LHEX PAS00343 W23 UF03 4
Any idea how I could do that?Have you tried DECODE? How many values of Serial_Number do you have?
[edit] Just a point - this "design" would be contrary to good normalisation principles - if you have a unique
value for every unique serial number, why not just use it? [edit]
Paul...
Edited by: Paulie on 13-Apr-2012 15:16 -
Change need in IKM SQL/Oracle incremental Update
according to my requirement:
IKM need to change as * DELETE existing records(NOt all some ) instead of update existing records *
insert all records(simply dump)
option change as:
update and Insert -----> as------>DELETE & insert
can anyone provide code to implement my logic...?Hi, as far as i understand your question you need to *" delete 1st then insert "* insted doing *"update and insert"*
Here you create one extra step with the existing IKM. suppose name it "Delete records"
in target tab
delete from <%snpRef.getTable("L","TARG_NAME","A")%> where condition (put ur desired condition)
selecte the schema refering to target,then select transaction 1-> commit
1st part is done.Now come to the second step.
In the existing ikm delete the step "flag rows for update","falg useles rows","update rows".
Thats all.
Thanks. -
Number Increment in Snart Form
Dear All,
In Test Certificate form i have to print TC No. which would be continious no. e.g when first time i will make a TC it would be 1, second time it should be 2, third time it would be 3, and so on.
Is it possible to do it with smart forms.
Regards,
Gulrez AlamHi
I think you want first time TC1 second time TC2
correct me if i am wrong
If you want to get the same make use of the field COPYCOUNT from SFSY in setting of the form
Regards
Shiva -
Increment a number column when a specific field is update
Hi,
I'm working on SharePoint and i'm looking for a solution to have a field which is incremented when a specific field is edited.
Example : i have a date field, with 16/07/2014 when i create an element. I edit this element and change this date field to 17/07/2014 so this increment my field to 1.
For each update on this element i'll need a test who's tell me if the previous date is equal do the new date.
I don't know if i can do that only with a calculated column or with a workflow.
Thanks in advance for your help !
RegardsIf you only needed a number incremented, then you could turn on versioning.
As you need to test to see if a field has changed and do something based on the change then you will need to:
Create a SharePoint Designer workflow
Write a Visual Studio workflow
or Write a Visual Studio event receiver
Mike Smith TechTrainingNotes.blogspot.com
Books:
SharePoint 2007 2010 Customization for the Site Owner,
SharePoint 2010 Security for the Site Owner
Maybe you are looking for
-
My iPod isn't synching. It's not even showing up in the Devices. I know it's ocnnected becasue it's charging. Help please! Probably an epic noob fail xD
-
Error while configuring ths schedule
Hi all, I was created the reports based on x server, i am able to see all the reports. At the time of configure the schedule option, i was provided the all information(database connection and all) after that i am selecting the install schema it is gi
-
3gb vs. 4gb on New iMac
Wondering if I would notice a considerable difference between 3gb and 4gb of ram installed in a new iMac. I was planning on leaving the 1gb stick installed and adding a 2gb stick, but have also considered replacing the installed stick with 2gb. I wil
-
I can't create an icolud account
I tried to setup icloud on my PC and when i'm trying to log into icloud to the control panel it writes: the apple ID is valid but it's not an icloud account
-
How do I contact Adobe support personnel directly with a question or problem? email? telephone?