Data format in rows and columns

I have a table and have the following data,I need to transpose int he required form.
The number of rows are dynamic and i dont want decode and string concatenation.
1     Tamil     1     1000
2     English     2     2000
3     Hindi     3     3000
4     German     4     4000
5     Telugu     5     5000
o/p
tamil english hindi german telegu
1 2 3 4 5
1000 2000 3000 4000 5000
The first column values will become the heading and all other corresponsing rows will become the column values
Kindly reply ,,Thaks in advance

how about this
assuming you've implemented the stragg function (see ask tom if not)
of course you can always use sys connect by path to roll the column values up into a single entry.
anyway use stragg or sys connect by path to get all the colum values into a single entry seperated by commas
col1 col2 col3
Tamil,English,Hindi,German,Telugu 1,2,3,4,5 1000,2000,3000,4000,5000
next I used the model clause to take the three columns one row construct
and change it to one column 3 rows so now the result set looks like this
col1
Tamil,English,Hindi,German,Telugu
1,2,3,4,5
1000,2000,3000,4000,5000
finally I appended a comma to the end of each row and parsed through it pulling out the text between columns
here is the whole thing...... again for this to work you need to have implemented the stragg function else you'll have to change to sys connect by path.
select col4 StraggedValues,
substr (col4, 1, instr(col4,',',1) -1) col1,
substr (col4, instr(col4,',',1)+1, instr(col4,',',1,2) - instr(col4,',',1)-1) col2,
substr (col4, instr(col4,',',1,2)+1, instr(col4,',',1,3) - instr(col4,',',1,2)-1) col3,
substr (col4, instr(col4,',',1,3)+1, instr(col4,',',1,4) - instr(col4,',',1,3)-1) col4,
substr (col4, instr(col4,',',1,4)+1, instr(col4,',',1,5) - instr(col4,',',1,4)-1) col5,
substr (col4, instr(col4,',',1,5)+1, instr(col4,',',1,6) - instr(col4,',',1,5)-1) col6,
substr (col4, instr(col4,',',1,6)+1, instr(col4,',',1,7) - instr(col4,',',1,6)-1) col7
from (
with a as
select stragg(col1) strCol1, stragg(col2) strCol2, stragg(col3) strCol3 from
select 1 rn, 'Tamil' col1, 1 col2, 1000 col3 from dual union
select 2 rn, 'English' col1, 2 col2, 2000 col3 from dual union
select 3 rn, 'Hindi' col1, 3 col2, 3000 col3 from dual union
select 4 rn, 'German' col1, 4 col2, 4000 col3 from dual union
select 5 rn, 'Telugu' col1, 5 col2, 5000 col3 from dual
select col4||',' col4 from a
model
return updated rows
dimension by (0 d)
measures (strcol1, strcol2, strcol3, 'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx' col4)
rules iterate (3)
col4[iteration_number + 1] = case iteration_number
when 0 then strcol1[0]
when 1 then strcol2[0]
when 2 then strcol3[0]
else null end
)) b

Similar Messages

  • Conditional Formating of rows and columns in template(cross tab)

    Hi,
    I am developing a cross tab report in which I have row header as the year like 2008,2007,2006....column header as months jan,feb,mar...and the data area contains the respective data...I need to format the background color of the rows and columns which are below the date of the report(report is ran for a particular month like mar-08)..I was able to format the background color of all the rows that fall below(ex:08) the year of the report(using <?if@row:row_name<'$first'?> <xsl::attribute name="background-color" xdofo:ctx="incontext">#C0D27F</xsl::attribute><?end if?>)..
    and I need to format the 3(till march) columns in the yr 2008
    Thanks...

    Hello..
    Thanks for the reply...
    I have report date as mm|yyyy...below is a sample data of the cross tab..
    <Q1>
    <REPORT_DATE>04|2005</REPORT_DATE>
    </Q1>
    <Q4>
    <CLASS_ID>1</CLASS_ID>
    <MONTH_BEGIN_DATE>JAN</MONTH_BEGIN_DATE>
    <BEGIN_DATE>2004</BEGIN_DATE>
    <NET_ROR>1.32</NET_ROR>
    <ACTUAL_DATE>01/01/2004</ACTUAL_DATE>
    <FUND_FACT_YTD>7.942192987387475647074276803933198866</FUND_FACT_YTD>
    </Q4>
    <Q4>
    <CLASS_ID>1</CLASS_ID>
    <MONTH_BEGIN_DATE>JAN</MONTH_BEGIN_DATE>
    <BEGIN_DATE>2005</BEGIN_DATE>
    <NET_ROR>-.21</NET_ROR>
    <ACTUAL_DATE>01/01/2005</ACTUAL_DATE>
    <FUND_FACT_YTD>5.739540457478967975310388578877768035</FUND_FACT_YTD>
    </Q4>
    <Q4>
    <CLASS_ID>1</CLASS_ID>
    <MONTH_BEGIN_DATE>FEB</MONTH_BEGIN_DATE>
    <BEGIN_DATE>2004</BEGIN_DATE>
    <NET_ROR>.59</NET_ROR>
    <ACTUAL_DATE>02/01/2004</ACTUAL_DATE>
    <YTD>7.942192987387475647074276803933198866</YTD>
    </Q4>
    <Q4>
    <CLASS_ID>1</CLASS_ID>
    <MONTH_BEGIN_DATE>FEB</MONTH_BEGIN_DATE>
    <BEGIN_DATE>2005</BEGIN_DATE>
    <NET_ROR>1</NET_ROR>
    <ACTUAL_DATE>02/01/2005</ACTUAL_DATE>
    <YTD>5.739540457478967975310388578877768035</YTD>
    </Q4>
    <Q4>
    <CLASS_ID>1</CLASS_ID>
    <MONTH_BEGIN_DATE>MAR</MONTH_BEGIN_DATE>
    <BEGIN_DATE>2004</BEGIN_DATE>
    <NET_ROR>0</NET_ROR>
    <ACTUAL_DATE>03/01/2004</ACTUAL_DATE>
    <YTD>7.942192987387475647074276803933198866</YTD>
    </Q4>
    <Q4>
    <CLASS_ID>1</CLASS_ID>
    <MONTH_BEGIN_DATE>MAR</MONTH_BEGIN_DATE>
    <BEGIN_DATE>2005</BEGIN_DATE>
    <NET_ROR>-.2</NET_ROR>
    <ACTUAL_DATE>03/01/2005</ACTUAL_DATE>
    <YTD>5.739540457478967975310388578877768035</YTD>
    </Q4>
    <Q4>
    <CLASS_ID>1</CLASS_ID>
    <MONTH_BEGIN_DATE>APR</MONTH_BEGIN_DATE>
    <BEGIN_DATE>2004</BEGIN_DATE>
    <NET_ROR>-.07</NET_ROR>
    <ACTUAL_DATE>04/01/2004</ACTUAL_DATE>
    <FUND_FACT_YTD>7.942192987387475647074276803933198866</FUND_FACT_YTD>
    </Q4>
    <Q4>
    <CLASS_ID>1</CLASS_ID>
    <MONTH_BEGIN_DATE>APR</MONTH_BEGIN_DATE>
    <BEGIN_DATE>2005</BEGIN_DATE>
    <NET_ROR>-.87</NET_ROR>
    <ACTUAL_DATE>04/01/2005</ACTUAL_DATE>
    <YTD>5.739540457478967975310388578877768035</YTD>
    </Q4>
    MONTH_BEGIN_DATE goes as the column header, BEGIN_DATE goes as the row header and NET_ROR is the data area..I need to get the background color of each cell of NET_ROR below the report date as one color...
    Thanks ..

  • How can i open a PDF bank statement in numbers so that the rows and columns contain properly aligned data from statement?

    how can i open a PDF bank statement in "numbers" so that the rows and columns contain properly aligned data from statement?

    Numbers can store pdfs pages or clippings but does not directly open pdf files.  To get the bank statement into Numbers as a table I would open the bank statment in Preview (or Skim) or some pdf viewer.
    Then hold the option key while selecting a column of data.
    Then copy
    Then switch to numbers and paste the column into a table
    Then repeat for the other columns in the pdf document
    It would be easier (in my opinion) to download the QFX or CSV version from your bank

  • Row and Column Formulas on a Data Form

    I am creating a data form which has both row and column formulas. I would like the row formulas to show for some of the cells but it seems to default to the column formula.
    How can I get my form to show the row formula result and not the column formula result?
    Thank you!

    Brian,
    See this example:
    http://htmldb.oracle.com/pls/otn/f?p=31517:160
    There are also a coupleof others showing the same thing you want to achive.
    Denes Kubicek
    http://deneskubicek.blogspot.com/
    http://www.opal-consulting.de/training
    http://htmldb.oracle.com/pls/otn/f?p=31517:1
    -------------------------------------------------------------------

  • Report Writer Row and Column Format

    Hi
    Was wondering if there is a possible solution to this :-
    Understand that column format is controlled by format groups. This means that all figures in the same column will take the same format (such as scaling and decimal place).
    Scenario is ->
                        Colunn #1 -> column set as displaying no decimal point       
    Rev                  120
    OP                      5
    OP margin %     4.2 -> how to set this to 1 decimal point. Any formula syntax that I can use?
    Regards.

    Hi Vinay,
    Based on my research, freezing row and column headers are different in table and matrix.
    In a table, if we want to freeze column header, we should make the changes in the first Static row group in Row Groups pane with Advanced Mode as you said. If we want to freeze row header, the table should have a group ahead, then we can enable “Repeat header
    rows on each page” and “Keep header visible while scrolling” options in Row Headers in Tablix Properties dialog box.
    In a matrix, if we want to freeze column header, we can enable “Repeat header columns on each page” and “Keep header visible while scrolling” options in Column Headers in Tablix Properties dialog box. If we want to freeze row header, we can enable “Repeat
    header rows on each page” and “Keep header visible while scrolling” options in Row Headers in Tablix Properties dialog box.
    Hope this helps.
    Thanks,
    Katherine Xiong
    Katherine Xiong
    TechNet Community Support

  • Rows and column limit on Data Grids

    Hello,
    anyone know if there's a limit for the number of rows and columns per page in the Data Grids?
    Thanks in advance

    There is not a limit. There is a default of 1024 rows, but you can change this.
    -- Chris

  • Exporting data in rows and columns and loading in RDBMS

    <p>I have a scenario wherein i want to export data from HyperionEssbase in <b>rows and coulmns</b> and <b>load it into</b><b>RDBMS</b>. I can load data into RDBMS using informatica if theflat file exported is in form of rows and columns.But when i exportthe file using Hyperion Essbase 9 i get it in from of alldimensions and then the fact value which is not how i want. I wantdata in relational from in flat file itself(row,column).</p><p>Looking forard to your suggestions..Thanks in advance..</p>

    <p>Thanks <b>willjordan</b> and <b>twakim</b> for yoursuggestions..</p><p> </p><p>I tried both the techniques and both worked...</p><p>With reference to the technique suggested by <b>twakim</b> , I was able to use that in Hyperion Essbase 9..But in myreal scenario the cube is in Hyperion Essbase 6.5.4.2..Can i usethis Custom defined functions in Hyperion Essbase 6.5.4.2..and ifso how as there is no concept of Analytical server there???</p><p> </p><p>Please help me in this issue???<br></p>

  • Maximum number of rows and columns in data form

    Hi,
    I wanted to know if there is a limitation to the number of rows and columns that can be displayed in a data form, in Hyperion planning 11.1.2.1 ?
    And what would be the most appropriate number of rows and columns to be included for optimum performance.
    Thanks.

    Hi,
    While its a fun fact to determine how much one can stuff into a web form, the reality is: how much can a user reasonably consume in a web form?
    And what would be the most appropriate number of rows and columns to be included for optimum performance
    You will find that the answer to this is by "what design makes a web form most usable?" And no, the users don't really know what they want from a design perspective, they see it in their head, but usually what they ask for is something that would look entirely different (huge).
    The next thing to think about is the use of member selection functions in the page axis. IDescendants(Entity) in a dropdown could cause issues just as easily as too many rows - and again make the drop down unusable for a user.
    If your question is a bit more technical, then consider this (somewhat oversimplified): Web forms are constructed by a process on the server. Objects are created based on the form's definition and used by the process that builds the form. The process uses Cartesian looping (lots of iterations) to construct the form cell by cell, starting at the top left and finishing up in the bottom right. If the form has a million cells on it, then the loop and all the code within it runs a million times. The capability of the server has a lot to do with how well it can handle this request, and how many it can handle at one time.
    The result of this is gobs of HTML and JavaScript. All of this has to be sent over a network to the requesting client. The client starts receiving the web page code and has to render it in the browser and run the JavaScript. The ability to do this is limited by the browser, the OS, and the hardware that the client is running on.
    And that's just rendering the page for use.
    Now it has to be interacted with on the client machine, and changes parsed, packaged, and sent back to the server.
    So the technical answer is, there can be many limitations to how many rows and columns a data form can have - none of which can truly be anticipated by anyone. This is why I put the part about usability first in this post.
    Regards,
    Robb Salzmann

  • How to display 2 dimensional data. i.e with rows and columns?

    Hi,
    I want to know how to display multiple, variable
    rows and columns that are got from the database through
    queries in forms.
    (i,e. a Matrix of Values,something similar to an Excel Spreadsheet).
    Is there a component in forms similar to JTABLE that is
    available in Java through which MULTIPLE, VARIABLE
    rows and columns can be displayed ?.
    I am not using a base table since this data is got thru
    a number of packages and procedures that are used in
    Loops.
    NOTE : I am using forms 6i.
    Thanks
    Sharath.

    I've heard Grant mention adding a Grid component to the Forms toolbox. From the context I would guess this is not yet even under development, so it's not going to be available anytime soon. And not for 6i.
    Sorry, APC

  • How to save data from JTable multiple rows and columns

    Hi Y_Not thanks for your help before...
    But what should I do if I want to get/save many data from many column and rows??

    i don't quite understand your (repeated) question. what is the problem with "multiple rows and columns". Y_NOT and i have shown you ways to access them.
    all you need are 2 loops: one around your number of rows and one around the number of columns or vice versa depending in which order you want to save things:
    for (int col = 0; col < data.size(); col++) {
        for (int row = 0 ; row < data[col].size(); row++) {
            // save your data
            saveData(data[col].getElementAt(row));
            // or use yourtable.getValueAt(row, col);
    }this is not a problem of Swing/Java but of simple algorithm...
    thomas

  • Suppress Overall result (both rows and columns side and its data)

    Hello all,
    I need to do some settings in BEx Query Designer, so that In BEx Analyzer, I don't see 'overall result' both on 'rows' and 'column' sides
    This is what I have done so far
    In 'rows' section, Properties of my KF (no. Products) then 'calculation' tab 'calculate result as'=Suppress result
    This way in BEx Analyzer I don't see the FIGURES/DATA for 'Result' and 'overall result' BUT 'result' and 'overall result' still exist both on rows and colum side even if there are not figures in them.
    Is there any property in BEx Designer so that I don't see 'overall result' at all
    Best regards
    Ahmad

    thanks for responding
    selecting a characteristic, properties, Display tab, Result lines: Always Suppress
    with this I don't see 'result'
    but 'overall result' result exist both on 'rows' and 'column' side alongwith its data.
    If I combine the above with this: selecting KF, properties, calucations, Calculate result as: Suppress result
    then
    I don't see the data in 'overall result' BUT 'overall result' still exist both on rows and column sides
    any setting so that 'overall result' completely vanishes
    Best regards
    Ahsan

  • How can I make Numbers respect the row and column locks in an Excel workbook opened in Numbers???

    I have a Windows server app that generates Excel workbooks to be emailed to political campaign volunteers to be loaded into Numbers on an iPad, edited, then emailed back to be posted to the server database.  There are two problems encountered:
    1.  The Excel workbook has the first row (column headings) and first column (route identifier) of cells locked, so that they will not scroll off the screen, but Numbers doesn't respect the locks, so when the user scrolls horizontally or vertically, the column headings and/or the route identifier scroll off the screen.
    2.  The Excel workbook has pop-up "tool-tip" type comments in certain column headings in order to provide the user with the acceptable entries for those columns, but Numbers does not respect those.  When the user touches any of the commented column heading cells, a context menu appears instead of the comment.
    What must I do in the Excel workbook sheets, or what settings can be made in Numbers to correct the above?

    I imported a Numbers '09 file into Numbers on the iPad.  All comments were removed during import. Frozen header row and column were retained.
    Thank you for your responses I must ask, however, when you refer to "importing" the Excel file, are you referring to a two step process whereby the Excel file is first converted by some other process into Numbers format, then opened in the Numbers application - which is what I have to do in my PC application to generate the Excel file, and reverse that process to convert the Excel back into my database format - or are you simply referring to opening the file in Numbers as "importing" it?  And please excuse any ignorance, as I'm not at all familiar with Apple's terminologies.  In fact, I don't own an iPad myself, but rather I have to depend on one of my clients to do the testing for me.
    I imported an XLSX file into Numbers on the iPad.  The file used "freeze panes" to "freeze" the first column and row. Only warning on import was that it changed fonts. It imported without the first row and column frozen and with no comments. Nothing I can do about the missing comments but it was a simple matter to turn the first column & row into headers and freeze them.
    Unfortunately this would not be an efficient  solution, since the end users are, for the most part, elderly political campaign volunteers who are fairly computer illiterate.  These workbooks are actually canvassing lists - known as walklists.  Their purpose is for the volunteers to interview voters, record the results of the interviews, and post the results to a database, which provides the campaigns with valuable strategizing capabilities.  Also, these workbooks have multiple pages - as many as 10 or more.  and from what I infer from the above, the setting changes would have to be made on each page.
    My whole intent in developing this iPad/Tablet methodology was to significantly reduce volunteer's work - which is a recruitment benefit - and eliminate paper.  While the latter would be accomplished, the former would not, and in fact would tend to increase it.  It's necessary to keep the first row - column headings - and the first column - the route identifier - from scrolling off the page, so that the volunteer won't have to keep scrolling up and down and right and left to know what the data are.
    Conclusion: Comments are not supported on the iPad version of Numbers.  Frozen headers are not imported from Excel but can be recreated easily.
    I was previously directed to the Apple website  http://www.apple.com/ipad/from-the-app-store/apps-by-apple/numbers.html which extols the wonders of the Numbers application.  About halfway down the page there's a section regarding, "Sliders steppers and pop-ups".  The web page states that pop-ups can be set up but, being a marketing site, gives no indication whatsoever as to how it's done.  I was hoping someone could tell my if there's any way to carry them over from an Excel file.

  • Row and Column Template ?

    Trying to create this thing but no matter what I do I keep getting this ridiculous error:
    Cannot create a linked row and column template based on
    the selected rows. The grid needs to have at least one data row that is
    not part of a row and column template.
    What does this mean?

    You can get your requirement done using the Row and Column Template
    You can not save a row and column template with all rows in a report. You have to exclude at least one data row, otherwise you
    will get the error that you mentioned.
    If you want to save all the rows as a template and re-use it in other report, you can insert a data row at the end of all rows and hide that.
    Now you can select the complete row set as a template by excluding the extra data row that you will insert & hide.
    If you want to link the template in other reports with same row set you must be very careful with the formatting as you need to apply
    inherit formatting before saving the template. I suggest to spend some time with the FR online documentation.
    Regards
    Ram

  • Summing the Rows and Columns in an Array

    I am importing a 2-dimensional array of integers.(which is held in a 2-dimensional array)
    I need to store the row sums and column sums in separate 1-dimensional arrays.
    I can get the integers in and print out a list along with the grand total(sum of all).
    But, how do I pass each row's and each column's value in to my sumRow and sumCol methods to get the sum for each row and each column?
    Can I do the row and column summing in the same "for" statement where I calculate the "grand total"? Or am I making this more difficult than it is?
    Would appreciate any help.
    This is what I have so far:
    import java.awt.Graphics;
    import java.applet.Applet;
    public class TwoWayTable extends Applet {
         int numRows;
         int numCols;
         int [] [] cell;
         int [] rowSum;
         int [] colSum;
         int grandTotal;
    public TwoWayTable(int [][] data){
    grandTotal = 0;
    cell = new int [data.length][data.length];
    for(int i = 0; i < data.length; i++)
    for(int j = 0; j < data.length; j++){
         cell[i][j] = data[i][j];
    grandTotal += cell[i][j];
         System.out.println(cell[i][j]);
    System.out.println(grandTotal);
    public int sumRow(int [] data2){
         int rowaccumulator=0;
         rowSum = new int[data2.length];
         for(int numRows = 0; numRows < rowSum.length; numRows++){
         rowaccumulator += rowaccumulator + rowSum[numRows];
              return(rowaccumulator);
    public int sumCol(int [] data3){
         int colaccumulator = 0;
         colSum = new int[data3.length];
         for(int numCols = 0; numCols < colSum.length; numCols++){
              colaccumulator += colaccumulator + colSum[numCols];
              return(colaccumulator);

    Thanks for your input.
    I'll make the changes that you suggest.(after this)
    My output prints:
    4 6 3 8 21
    9 1 5 3 18
    13 7 8 11 39
    numbers are right, but I need to format the table
    the output needs to look like this:
    int int int int | rowsum
    int int int int | rowsum
    colsum colsum colsum colsum | total
    How do I do this?
    I have no idea?
    I'm supposed to call a "void setMargins( )" method to line this up, without
    using the exotic formatting in the IO library.
    I'm also supposed to use "public String toString( )"
    This is what I have so far:
    import java.awt.Graphics;
    import java.applet.Applet;
    public class TwoWayTable extends Applet {
    int numRows;
         int numCols;
         int [] [] cell;
         int [] rowSum;
         int [] colSum;
         int grandTotal;
    public TwoWayTable(int [][] data){
    cell = new int [data.length][data.length];     
    for(int i = 0; i < data.length; i++){
    for(int j = 0; j < data.length; j++){
         cell[i][j] = data[i][j];
    calcTotals(cell);
    for(int i = 0; i < cell.length; ++i){
    for(int j = 0; j < cell.length; ++j){
    System.out.print(cell[i][j] + " ");
    System.out.println(rowSum[i] + " ");
    for(int j = 0; j < cell.length-1; ++j){
    System.out.print(colSum[j] + " ");
    System.out.println(colSum[cell.length-1] + " " + (grandTotal));
         public void calcTotals(int [][] data2){
              grandTotal = 0;
              rowSum = new int[data2.length];                         
              colSum = new int[data2.length];                         
              for(int numRows = 0; numRows < data2.length; numRows++){
              for(int numCols = 0; numCols < data2.length; numCols++){
                   grandTotal += data2[numRows][numCols];               
                   rowSum[numRows] += data2[numRows][numCols];
                   colSum[numCols] += data2[numRows][numCols];

  • How do I delete multiple rows and columns in an image?

    I am looking into how digital SLRs extract video data from a CMOS sensor. To give an example, the GH1 from Panasonic can record video at 1920 x 1080 from a 12 MPixel sensor that, say, is 4000 horizontal x 3000 vertical. How they do that seems to be not in the public domain, but there have been a few guesses (see http://www.dvxuser.com/V6/showthread.php?t=206797 and http://luminous-landscape.com/forum/index.php?showtopic=38713).
    One approach would be to simply read every second row of sensor pixels (1500 rows read from the original 3000) and once you have those in memory, delete every second column (2000 columns left). You would end up with a 2000 x 1500 image which could then be resampled to 1920 x 1080.
    I'd like to simulate what the camera appears to be doing, by generating a 4000 x 3000 test image and then asking Photoshop CS4 to delete the appropriate rows and columns. It may not necessarily be every second row; the Canon 5DMk11 appears to read every third row, so I may need to delete two out of every three rows.
    Can Photoshop do that sort of thing? If so, how?

    Thanks for the suggestions. Yes, I did take a detailed look at your images, but they weren't 100% convincing because it wasn't clear just what was happening. And Adobe's explanation, after reading it again, explains nothing at all to someone who doesn't know how Nearest Neighbor works.
    But you are correct -- Nearest Neighbor does effectively delete pixels. I proved it with the attached 6 x 6 image of coloured pixels (the tiny midget image right after this full stop -- you'll have to go to maximum zoom in PS to see it).
    These are the steps to delete every second row and then every second column.
    1. Select Image > Image Size.
    2. Set Pixel Dimensions > Height to half the original (in this case set to 3 pixels).
    3. Set Resample Image to Nearest Neighbor.
    4. Click OK and the image shoould now consist of three vertical white strips and three vertical Green-Red-Blue stripes.
    5. Repeat steps 1-4, but this time set Pixel Dimensions > Width to half the original (in this case set to 3 pixels). The image should now consist of three horizontal stripes Green-Red-Blue.
    Just to make sure the method worked for every third pixel, I repeated the above steps but with 2 pixels instead of 3 and obtained the correct White-Green, White-Green pattern.
    I resampled the Height and Width separately for the test so that I could see what was happening. In a real example, the height and width can be changed at the same time in the one step, achieving the same results as above.
    Finally, how to explain how Nearest Neighbor works in the simple cases described above?
    Division by 2
    In the case of an exact division by two (pixels numbered from top leftmost pixel), only the even numbered rows and columns remain. To put it a different way, every odd numbered row and column are deleted.
    Division by 3
    Only rows and columns 2, 5, 8, 11... remain.
    Division by N
    Only rows and columns 2, 2+N, 2+2N, 2+3N... remain.
    To put it simply, a resample using Nearest Neighbor (using an exact integer multiple) keeps every Nth row and column, starting from number two. The rest are deleted.

Maybe you are looking for