Add a row after every n records
Hi
I have a query that returns only one column
Column1
a
b
c
d
g
e
f
g
h
I want to add 01 as the first row and then after 5 records i want to add 02 then 03 after another 5 records and so on i.e
Column1
01
a
b
c
d
e
02
f
g
h
How can this be done?
Hi,
Nice post.
Regards salim.
other solution.
SELECT res
FROM t
model
dimension by( row_number()over(partition by 1 order by rownum) rn)
measures(col1,cast ( col1 as varchar2(20)) as res, count(1)over(partition by 1) cpt,trunc(rownum/5) diff)ignore nav
(diff[for rn from 1 to cpt[1]+trunc((cpt[1]+cpt[1]/5)/5) increment 1]=
case when diff[cv(rn)] is present then diff[cv(rn)]
else case when mod(cv(rn),5)=0 then
diff[cv(rn)-1]+1
else diff[cv(rn)-1]end
end,
res[for rn from 1 to cpt[1]+trunc((cpt[1]+cpt[1]/5)/5) increment 1]=
case when mod(cv(rn),5)=0 then
to_char((cv(rn)/5),'fm00')
else col1[cv(rn)-diff[cv(rn)]]end )
SQL> WITH t AS
2 (SELECT 'a' col1
3 FROM DUAL
4 UNION ALL
5 SELECT 'b'
6 FROM DUAL
7 UNION ALL
8 SELECT 'c'
9 FROM DUAL
10 UNION ALL
11 SELECT 'd'
12 FROM DUAL
13 UNION ALL
14 SELECT 'g'
15 FROM DUAL
16 UNION ALL
17 SELECT 'e'
18 FROM DUAL
19 UNION ALL
20 SELECT 'f'
21 FROM DUAL
22 UNION ALL
23 SELECT 'g'
24 FROM DUAL
25 UNION ALL
26 SELECT 'h'
27 FROM DUAL
28 UNION ALL
29 SELECT 'i'
30 FROM DUAL
31 UNION ALL
32 SELECT 'j'
33 FROM DUAL
34 UNION ALL
35 SELECT 'k'
36 FROM DUAL
37 UNION ALL
38 SELECT 'l'
39 FROM DUAL
40 UNION ALL
41 SELECT 'm'
42 FROM DUAL
43 UNION ALL
44 SELECT 'o'
45 FROM DUAL
46 UNION ALL
47 SELECT 'p'
48 FROM DUAL
49 UNION ALL
50 SELECT 'q'
51 FROM DUAL
52 UNION ALL
53 SELECT 'z'
54 FROM DUAL
55 UNION ALL
56 SELECT 'z'
57 FROM DUAL
58 UNION ALL
59 SELECT 'z'
60 FROM DUAL
61 UNION ALL
62 SELECT 'y'
63 FROM DUAL)
64 SELECT res
65 FROM t
66 model
67 dimension by( row_number()over(partition by 1 order by rownum) rn)
68 measures(col1,cast ( col1 as varchar2(20)) as res, count(1)over(partition by 1) cpt,trunc(rownu
m/5) diff)ignore nav
69 (diff[for rn from 1 to cpt[1]+trunc((cpt[1]+cpt[1]/5)/5) increment 1]=
70 case when diff[cv(rn)] is present then diff[cv(rn)]
71 else case when mod(cv(rn),5)=0 then
72 diff[cv(rn)-1]+1
73 else diff[cv(rn)-1]end
74 end,
75 res[for rn from 1 to cpt[1]+trunc((cpt[1]+cpt[1]/5)/5) increment 1]=
76 case when mod(cv(rn),5)=0 then
77 to_char((cv(rn)/5),'fm00')
78 else col1[cv(rn)-diff[cv(rn)]]end )
79
SQL> /
RES
a
b
c
d
01
g
e
f
g
02
h
i
j
k
03
l
m
o
p
04
q
z
z
z
05
y
26 ligne(s) sélectionnée(s).
SQL> Edited by: Salim Chelabi on 2009-04-15 13:35
Similar Messages
-
How to add a row for every 5 records using logic:iterate
Hi,
In my application, using logic:iterate iam displaying 20 records per page.
I want to insert a row for every 5 records.
Please tell how to insert that row.
Thanks in advance.
MohanI think this could work for you
for (int x=1 ; x<=20 ; x++) {
addRowWithRecord
if (x%5==0)
addEmptyRow
} -
Dear Friiends,
I would like to write down query which also returns the total of some columns after every 25 records.
like this
ccno salary
1 5000
2 10000
25 80000
total <total of above 25>
26 25000
27 10000
50 13000
total <total of above 50>
can we achieve this
Waiting for reply .with tab as (
select 1 ccno,100 salary from dual union all
select 2 ccno,200 salary from dual union all
select 3 ccno,300 salary from dual union all
select 4 ccno,400 salary from dual union all
select 5 ccno,500 salary from dual union all
select 6 ccno,600 salary from dual union all
select 7 ccno,700 salary from dual
)--end of test data
select ccno,
salary,
case when mod(row_number() over (order by ccno), 3) = 0 then sum(salary) over (order by ccno) else null end as sumsal
from tab
CCNO SALARY SUMSAL
1 100
2 200
3 300 600
4 400
5 500
6 600 2100
7 700
7 rows selectedChange the 3 in the mod to 25 for your data -
Insert Blank row After every Row in alv report
How to insert blank row After every row in Alv report
what do you mean by a 'blank row'? ALV displays tabular data with 'any' number of columns. Now if you actually want a blank row (no columns at all, just a row), then that is just not possible. If I'm not mistaken, this question was posted before, so try to do a search on SCN. See what is says.
-
Add a row after Total row in ALV report
Hi Experts,
I have a report is displayed by ALV format(not use function module to display it but use Class cl_gui_custom_container),I want to add a row after the total row. for example,
Customer amount1 amount2 amount3
10000 1,234 1,000 2,000
10001 4,000 2,000 1,000
10002 1,300 1,000 3,000
11000 1,200 4,000 3,000
Total: 7,734 8,000 9,000
Ratio% 31.27 32.34 36.39
the row of 'Total' is calculated by fieldcat-do_sum = 'X' But after the Total row we need a Ratio row to display the ratio. Yes we can calculate the total amout and ratio and then append it into the output itab, but we don't like this solution.We want to keep the total function in the ALV report.Any experts can poit me a direction. Thanks in advance.
JoeDjoe,
First you need to handle the user command,in order to capture the button action. For this you need to implment a class, i am attaching sample codes here
In top include write the following code
CLASS lcl_event_handler DEFINITION .
PUBLIC SECTION .
METHODS:
handle_toolbar FOR EVENT toolbar " To add new functional buttons to the ALV toolbar
OF cl_gui_alv_grid
IMPORTING e_object,
handle_user_command FOR EVENT user_command " To implement user commands
OF cl_gui_alv_grid
IMPORTING e_ucomm .
PRIVATE SECTION.
ENDCLASS. " Lcl_event_handler DEFINITION
Now <b>Class implementation</b>
CLASS lcl_event_handler IMPLEMENTATION .
METHOD handle_toolbar. " Handle Toolbar
PERFORM f9500_handle_toolbar USING e_object.
ENDMETHOD . " Handle_toolbar
METHOD handle_user_command . " Handle User Command
PERFORM f9600_handle_user_command USING e_ucomm .
ENDMETHOD.
ENDCLASS . " lcl_event_handler IMPLEMENTATION
FORM f9600_handle_user_command USING p_e_ucomm TYPE sy-ucomm.
CONSTANTS:c_newl(4) TYPE c
VALUE 'NEWL', " New line
c_copy(4) TYPE c
VALUE 'COPY', " Copy
c_corr(4) TYPE c
VALUE 'CORR'. " Correction
CASE p_e_ucomm .
WHEN c_newl.
Create a new line
PERFORM f9610_insert_new_line.
ENDFORM. " f9600_handle_user_command
FORM f9610_insert_new_line .
*Data Declarations
DATA: lt_rows TYPE lvc_t_row, " Itab for row property
ls_rows TYPE lvc_s_row, " Work area for row
lv_cntid TYPE i. " Counter
DATA: gv_index TYPE sy-index.
CLEAR gs_last.
CALL METHOD gr_alvgrid->get_selected_rows
IMPORTING
et_index_rows = lt_rows.
READ TABLE lt_rows INTO ls_rows INDEX 1.
IF sy-subrc EQ 0.
gv_index = ls_rows-index + 1.
ELSE.
gv_index = 1.
ENDIF.
DESCRIBE TABLE gt_last LINES lv_cntid.
lv_cntid = lv_cntid + 1.
gs_last-cntid = lv_cntid.
INSERT gs_last INTO gt_last INDEX gv_index.
LOOP AT gt_last INTO gs_last FROM gv_index TO gv_index.
Make the new line editable
PERFORM f9611_style.
ENDLOOP.
CALL METHOD gr_alvgrid->refresh_table_display
EXCEPTIONS
finished = 1
OTHERS = 2.
ENDFORM. " f9610_insert_new_line
You can ask questions doubts if any!
regards
Antony Thomas -
Commit in procedures after every 100000 records possible?
Hi All,
I am using an ODI procedure to insert data into a table.
I checked that in the ODI procedure there is an option of selecting transaction and setting the commit option as 'Commit after every 1000 records'.
Since the record count to be inserted is 38489152, I would like to know is this option configurable.
Can i ensure that commits are made at a logical step of 100000 instead of 1000 records?
Thank You.
Prernarecently added on this
http://dwteam.in/commit-interval-in-odi/
Thanks
Bhabani
http://dwteam.in -
ResultSet "hangs" after every 10 records
Hi
Please could you somebody help me.
I have extracted a ResultSet from a database which contains between 100 and 200 records (5 field each).
If I call rset.next(), printing a count after each call my program hangs for about 2 minutes after every 10 records.
For example:
int count = 0;
while(rset.next()) {
System.out.println("" + ++count);
Prints:
1
2
3
4
5
6
7
8
9
10
Waits here for two minutes and then carries on
11
20
Waits again for 2 minutes etc.
Has anyone had this problem or does anyone know how to fix it?
FYI: prstat reports tiny CPU and memory usage so the hardware is not responsible.
Thanks a lot in advanceHi All
It must be network - setFetchSize is unsupported in both Statement and ResultSet in the driver set I am using.
It is running through a 10baseT switch at the moment which may be the problem so I will stick it on the backbone and try again.
Thanks again for your help. -
Add 3 zero after every n element in an array
Hi, I have an array that has 50 elements ( 0 and 1) . I would like to add 3 zero after every 5 elements . As below for the first 10 elements
10101010111111101001 should become 10101010110001111101001000
could you please help me on this one ? I would greatly appreciate if youd attach the code for it
thanksApproach with for loop
"In theory, theory and practice are the same. In practice, they’re not." -
Hope someone can help me.
What I basically need help with is how to make Acrobat add a comma after every 6 characters in a text field:
XXXXXX,YYYYYY, ZZZZZZ etcI'm sorry, but I did not understand that (i'm using Acrobat Pro X)
Am I supposed to go to:
Text Field Properties > Format > Custom
and then use Custom Format Script or Custom Keystroke Script?
I tried both and it did not work.
And do the Text Field have to be named "chunkSize"?
Seems like it works. I had to move to the next formfield in order to see the effect.
Is it possible to make it happen in real time (as you type the comma is inserted?) -
Commit after every 1000 records
Hi dears ,
i have to update or insert arround 1 lakhs records every day incremental basis,
while doing it , after completing all the records commit happens, In case some problem in between all my processed records are getting rollbacked,
I need to commit it after every frequency of records say 1000 records.
Any one know how to do it??
Thanks in advance
Regards
RajaRaja,
There is an option in the configuration of a mapping in which you can set the Commit Frequency. The Commit Frequency only applies to non-bulk mode mappings. Bulk mode mappings commit according the bulk size (which is also an configuration setting of the mapping).
When you set the Default Operating Mode to row based and Bulk Processing Code to false, Warehouse Builder uses the Commit Frequency parameter when executing the package. Warehouse Builder commits data to the database after processing the number of rows specified in this parameter.
If you set Bulk Processing Code to true, set the Commit Frequency equal to the Bulk Size. If the two values are different, Bulk Size overrides the commit frequency and Warehouse Builder implicitly performs a commit for every bulk size.
Regards,
Ilona -
DG4ODBC adds black spaces after every character
I am trying to set up HS using Oracle 10.2.0.5 on RHEL5 (64 bit), FreeTDS, and MS SQL Server.
The ODBC Driver works fine:
[oracle@phsbe1pr ~]$ isql sfasql_freetds_dsn sqlSinfoOne ***
| Connected! |
| |
| sql-statement |
| help [tablename] |
| quit |
| |
SQL> select name, len( name ) from sys.objects where object_id < 20 ;
---------------------------------------------------------------------------------------------------------------------------------------------+
| name | |
---------------------------------------------------------------------------------------------------------------------------------------------+
| sysrscols | 9 |
| sysrowsets | 10 |
| sysallocunits | 13 |
| sysfiles1 | 9 |
| syspriorities | 13 |
| sysfgfrag | 9 |
---------------------------------------------------------------------------------------------------------------------------------------------+
SQLRowCount returns 6
6 rows fetched
SQL> quit
[oracle@phsbe1pr ~]$
[oracle@phsbe1pr ~]$ tsql -S SFASQL_FreeTDSName -U sqlSinfoOne -P ***
locale is "en_US.UTF-8"
locale charset is "UTF-8"
using default charset "UTF-8"
1> select name, len( name ) from sys.objects where object_id < 20
2> order by 1
3> go
name
sysallocunits 13
sysfgfrag 9
sysfiles1 9
syspriorities 13
sysrowsets 10
sysrscols 9
(6 rows affected)
1> exit
[oracle@phsbe1pr ~]$
But when I use the dblink i got every string doubled with spaces after every char:
[oracle@phsbe1pr ~]$ sqlplus / as sysdba
SQL*Plus: Release 10.2.0.5.0 - Production on Mon Jul 23 17:22:25 2012
Copyright (c) 1982, 2010, Oracle. All Rights Reserved.
Connected to:
Oracle Database 10g Enterprise Edition Release 10.2.0.5.0 - 64bit Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options
SQL> set linesize 120
SQL> column name format a40
SQL> select "name", length ( "name" )
2 from sys.objects@sfasql_link
3 where "object_id" < 20
4 order by 1
5 /
name LENGTH("NAME")
s y s a l l o c u n i t s 26
s y s f g f r a g 18
s y s f i l e s 1 18
s y s p r i o r i t i e s 26
s y s r o w s e t s 20
s y s r s c o l s 18
6 rows selected.
SQL>
What can I do ?
Mi init.ora is:
HS_FDS_CONNECT_INFO = SFASQL_DSN
HS_FDS_SHAREABLE_NAME = /usr/lib64/libodbc.so
HS_FDS_TRACE_LEVEL = off
HS_FDS_TRACE_FILE_NAME=/tmp/odbc_hs_sfa.trc
HS_FDS_SQLLEN_INTERPRETATION = 32
set ODBCINI=/etc/odbc.ini
adn odbc.ini contains:
[SFASQL_DSN]
Description = sqlserver
Driver = FreeTDS
# Servername = SFASQL_FreeTDSName
Server = phsspbe.perfumeholding.intra
Address = 172.17.0.45
Port = 1433
Database = SFA_INTERSCAMBIO
TDS_Version = 8.0
Language = us_english
TextSize = 1999
PacketSize = 1470
ClientCharset = ISO-8859-1
DumpFile = /tmp/odbc_sfasql_dsn.log
DumpFileAppend = Yes
DebugFlags =
Encryption = off
#Trace = Yes
#TraceFile = /tmp/odbc_sfasql_dsn.trc
Thank you for every answer!
Andrea1. Please add to the gateway init file HS_NLS_NCHAR=UCS2
Then test again with a new SQL*Plus session.
When it continues to fail, what's the character set of the Oracle database being used and how did you set the NLS_LANG in your environment? -
How Do I get SSIS To Stop Looping Through Excel Rows After Last Populated Record?
I have a package that loops through many excel files. Each Excel File has about 5000 rows. My problem is that after the 5000th row SSIS keeps looping through all the rows after the last row. There are nothing in these rows. This is a complete bottleneck
of my package because it takes forever when doing this. How do I stop this?
ThanksAnother way is to specify the range in select statement which can be done in two ways
http://getsetsql.blogspot.in/2012/01/using-ssis-load-data-to-excel-sheet-at.html
http://sqlserversolutions.blogspot.in/2009/02/selecting-excel-range-in-ssis.html
Please Mark This As Answer if it solved your issue
Please Vote This As Helpful if it helps to solve your issue
Visakh
My Wiki User Page
My MSDN Page
My Personal Blog
My Facebook Page -
Every time I reboot, when I lauch Firefox, I get one tab for each "installed" extension, asking to "allow the install" of the extension.
Now that I'm thinking about it, the problem persists since firefox 5 or 6, but it is only now at 8 that it shows me a tab for each extension. Before the alerts were hidden in the extensions manager.
So, After I installed the extension, there is no reason to ask me again and again to "install it" or "allow it".
The "add-on compatibility reporter" I installed only a couple of days ago, so I can have Google toolbar back.
How can I get rid of this absurd problem?Do not double-click the file, but use "Open with" in the right-click context menu to open the file in a text editor like Notepad.
You can copy the file to another folder or let Windows create a copy with a number appended to the name in the same folder. -
Add period after every footnote number
I have a document with footnotes in the Word style, with the number superscripted. I want the footnote reference in the text to be superscripted, but not the corresponding number on the footnote. I'd like that to be the same size as the footnote text. I can change all these using find/change, but while I'm at it, I would like to add a period after every footnote number. Would someone be willing to suggest a way to do this? Thanks.
I'd suggest experimenting with the "Separator" category under Type > Document Footnote Options.
-
Adding row after subtotal in ALV
Hi Guys,
can we add one row after the subtotal in ALV.
Like the below...
field1 field2 field3 field4
Sub total. 120 121 125 130
Test 150
can you help me about the above...
Thanks,
LingeshHi
If you use GROUPLEVEL_CHANGE you have to creare a form like this:
FORM GROUPLEVEL_CHANGE
USING P_LINEINFO TYPE SLIS_LINEINFO
LS_GROUPS TYPE KKBLO_GROUPLEVELS.
ENDFORM. "GROUPLEVEL_CHANGE
In the P_LINEINFO you have details of row and in the LS_GROUPS details of level of sorting.
For example I used it to re-write subtotal:
FORM GROUPLEVEL_CHANGE USING P_LINEINFO TYPE SLIS_LINEINFO
LS_GROUPS TYPE KKBLO_GROUPLEVELS.
PERFORM WRITE_SUB_TOTAL USING LS_GROUPS.
ENDFORM. "GROUPLEVEL_CHANGE
FORM WRITE_SUB_TOTAL USING P_GROUPS TYPE KKBLO_GROUPLEVELS.
DATA: TOT_SALDO_A LIKE BSID-DMBTR,
TOT_FATTURATO_A LIKE BSID-DMBTR,
TOT_DSO_A LIKE BSID-DMBTR.
DATA: WA_GROUP TYPE KKBLO_GROUPLEVELS.
DATA: RUN_LEVEL TYPE I.
DATA: BEGIN OF T_LEVEL OCCURS 1,
LEVEL TYPE I,
INDEX_FROM TYPE I,
INDEX_TO TYPE I,
END OF T_LEVEL.
T_LEVEL-LEVEL = P_GROUPS-LEVEL.
T_LEVEL-INDEX_FROM = P_GROUPS-INDEX_FROM.
T_LEVEL-INDEX_TO = P_GROUPS-INDEX_TO.
APPEND T_LEVEL.
Check livel:
CALL FUNCTION 'ALV_GROUPLEVELS_GET'
IMPORTING
ET_GROUPS = GT_GROUP
TABLES
T_OUTTAB = <FS_OUTPUT>.
RUN_LEVEL = P_GROUPS-LEVEL + 1.
IF RUN_LEVEL <= LEVEL.
DO.
LOOP AT GT_GROUP INTO WA_GROUP
WHERE INDEX_FROM => P_GROUPS-INDEX_FROM
AND INDEX_TO <= P_GROUPS-INDEX_TO
AND LEVEL = RUN_LEVEL.
T_LEVEL-LEVEL = RUN_LEVEL.
T_LEVEL-INDEX_FROM = WA_GROUP-INDEX_FROM.
T_LEVEL-INDEX_TO = WA_GROUP-INDEX_TO.
ENDLOOP.
IF SY-SUBRC = 0.
APPEND T_LEVEL.
ENDIF.
RUN_LEVEL = RUN_LEVEL + 1.
IF RUN_LEVEL > LEVEL. EXIT. ENDIF.
ENDDO.
ENDIF.
SORT T_LEVEL BY LEVEL DESCENDING.
LOOP AT T_LEVEL.
TOT_SALDO_A = TOT_FATTURATO_A = 0.
LOOP AT <FS_OUTPUT> INTO <FS_WA_OUT>
FROM T_LEVEL-INDEX_FROM
TO T_LEVEL-INDEX_TO.
ASSIGN COMPONENT 'ZSALDO'
OF STRUCTURE <FS_WA_OUT> TO <FS_SALDO>.
ASSIGN COMPONENT 'ZFATTURATO'
OF STRUCTURE <FS_WA_OUT> TO <FS_FATTURATO>.
TOT_SALDO_A = TOT_SALDO_A + <FS_SALDO>.
TOT_FATTURATO_A = TOT_FATTURATO_A + <FS_FATTURATO>.
ENDLOOP.
TOT_SALDO = TOT_SALDO + TOT_SALDO_A .
TOT_FATTURATO = TOT_FATTURATO + TOT_FATTURATO_A.
PERFORM CALCULATE_DSO USING TOT_FATTURATO_A
TOT_SALDO_A TOT_DSO_A.
PERFORM WRITE_TOT_DSO
USING TOT_SALDO_A
TOT_FATTURATO_A TOT_DSO_A
T_LEVEL-LEVEL T_LEVEL-INDEX_FROM.
ENDLOOP.
ENDFORM. " WRITE_SUB_TOTAL
Max
Maybe you are looking for
-
How to increase speed of analog read using PCI 6110 and LabView 7.1?
Hi All, I'm a fairly novice user of LabView and I'm trying to figure out how to make my system as fast as possible. Basically, I'm reading in an analog signal (AI0) together with a trigger signal (PFI0) and I want to sample the analog signal on the f
-
How to remove confirmation prompt when deleting from network share on Windows 8?
Regarding the question, on Windows 7 if I uncheck "Display delete confirmation dialog" I could delete a file without confirmation whether it's on local or network share but in Windows 8 this only affects the data on local drive only and if I try to d
-
VPN device profiling issue ISE In Line with ASA
Hi all, We have an inline posture ISE which is acting as a radius server for authenticating VPN client through our ASA. However because VPN client do not send thier MAC like they do when wireless and wired clients, the ISE cannot profile based on MAC
-
i can't seem to close individual tabs anymore, the (x) has dissapeared.? also, i cant seem to quit my internet. right click and quit ?? could some one please help meeee? thanks
-
While configuring omwb its asking for plugins. not able to find plugins
Hi after registring it is asking for plugins. failed to search for SQL_SERVER2K.Jar file. Can you help me when can i find the file to down load. or otherwise. Thanks in advance Bhaskar [email protected]