How to create a Pivot table without aggregate function

Dear team
I have the following table. Follow the link to download SQL Script to create table
https://drive.google.com/file/d/0B5nQIsvTifixV2Jkb043bVd2Zlk/view?usp=sharing
I want to create a pivot or cross tab so that it appear like this
LocationDesc
>=360
>=300
>=270
>=240
<240
Port Moresby
John Aita
Mawe Felix
Augustine Eri Luke
Joseph Aura
Robert  ROAKEINA
Port Moresby
Ambane Gigmai
Paul Dem
Henry  Wanpis
Tiniki Bau
William Laki NIGINTS
Port Moresby
June Vutnamur
Alphonse Waieng
Rex TOMARA
Mika OROMOIA
Eveni Ekeni
Mount Hagen
Dominic Kouroi
Senis Ospea
JOSEPH KLAWA
Peter WAI
PHILIP JAMES
Lae 
Henry TIAS
Mathew Dominic
Jobert Idigel
Wagi Jerry
Christopher Bianta
etc
etc
etc
etc
etc
etc
Marsh Narewec

Hi Marsh,
To achieve your requirement, you may reference the below query.
--pivot the table to get the expected output
;WITH cte AS(
SELECT *,ROW_NUMBER() OVER(PARTITION BY LocationDesc,BandGroup ORDER BY BandGroup) AS rn FROM [TmpBandGroup]
SELECT LocationDesc,[>=360],[>=300],[>=270],[>=240],[<240]
FROM cte
PIVOT
(MAX(EmployeeName) FOR BandGroup IN([>=360],[>=300],[>=270],[>=240],[<240])) PVT
ORDER BY LOCATIONDESC
--the pivot result can be validated with the queries below
;WITH cte AS(
SELECT *,ROW_NUMBER() OVER(PARTITION BY LocationDesc,BandGroup ORDER BY BandGroup) AS rn FROM [TmpBandGroup]
,cte2 AS
SELECT RN, LocationDesc,[>=360],[>=300],[>=270],[>=240],[<240]
FROM cte
PIVOT
(MAX(EmployeeName) FOR BandGroup IN([>=360],[>=300],[>=270],[>=240],[<240])) PVT
SELECT LocationDesc, COUNT([>=360]) [>=360] ,COUNT([>=300]) [>=300],COUNT([>=270]) [>=270],COUNT([>=240]) [>=240],COUNT([<240]) [<240]
FROM cte2
group by LocationDesc
ORDER BY LocationDesc
SELECT LocationDesc,bandgroup,COUNT(EmployeeName) FROM [TmpBandGroup] group by LocationDesc ,bandgroup
ORDER BY LocationDesc,bandgroup DESC
If you have any feedback on our support, you can click
here.
Eric Zhang
TechNet Community Support

Similar Messages

  • Question on how to create a pivot table

    Hi,
    I am trying to create a dynamic pivot table (the number of column and row layers change for each request) and I cannot use a data base structure to back it up.
    I thought of doing it through a managed bean but in order to do it I need to know how to create the PivotTableModel.
    The pivot table model requires a data source object and I do not know how to create it to support multiple row and column layers.
    Is there a default data source object that I can extend, or better yet is there a written example on how to create a pivot table model using a managed bean.
    Thanks,
    Or

    Hi,
    duplicate of ADF -11g : Question on how to create a pivot table

  • ADF -11g : Question on how to create a pivot table

    Hi,
    I am trying to create a dynamic pivot table (the number of column and row layers change for each request) and I cannot use a data base structure to back it up.
    I thought of doing it through a managed bean but in order to do it I need to know how to create the PivotTableModel.
    The pivot table model requires a data source object and I do not know how to create it to support multiple row and column layers.
    Is there a default data source object that I can extend, or better yet is there a written example on how to create a pivot table model using a managed bean.
    Thanks,
    Or
    Edited by: user638363 on Dec 18, 2008 7:02 AM

    Hi,
    beyond the documentation, the pivot table is described in
    http://technology.amis.nl/blog/2593/adf-faces-11g-reloading-the-matrix-using-the-pivot-table-component
    http://technology.amis.nl/blog/3786/creating-a-salary-heat-map-with-the-adf-11g-faces-pivottable-component
    http://technology.amis.nl/blog/3673/adf-11g-richfaces-a-closer-look-at-the-pivot-table-data-visualization-component
    I am not aware of any sample that directly meets your requirement
    Frank

  • How to create a pivot table similar to excel

    I would like to learn how to create a pivot table, similar to excel, thanks.
    Jmortiz

    Numbers does not have  pivot table function but can sort data, and summarize data.  If you can provide an example of the data you want to analyze I am certain we can help you in building summary tables.

  • How to create a pivot table from backing bean

    Hi,
    I need to create a pivot table from backing without having to create a Data Control.
    I searched a lot but all comes to a Data Control, and uses backing bean to manipulate data or to display popup info.
    Kindly advice if it can be done.
    Links and documentation is appreciated.
    sample is highly recommended.
    Thank you in advance
    Emile BITAR

    Hi,
    have a look at: http://www.oracle.com/technology/products/adf/adffaces/11/doc/multiproject/dvt/tagdoc/af_pivotTable.html
    It should provide all the infromation you need
    Frank

  • How to create a Dynamic table without knowing fieldcat size

    Hi all, i'm trying to insert a (Jointer) of 3 selections form diffrent tables in an other dynamic table but i dont know the size of my final table, so i dont know how to create a fieldcatalog.
    Can we create an internal table with those caractiristics ????

    Hi,
    If you know which fields (ABAP Dictionary) you're selecting then you know their size; use the following FM call: DD_NAMETAB_TO_DDFIELDS
    Then you can use the following method to create your dynamic table: cl_alv_table_create=>create_dynamic_table
    Arash

  • Pivot table wihtout Aggregate Functions ( Urgent Please. )

    I am trying to select date and time. But having a hard time since I dont have any aggregate function that is needed. Just pivot the rows to columns.
    IN sql 
    stage
    starttime
    endtime
    1
    1/22/2011 15:31
    1/22/2011 15:32
    2
    1/22/2011 15:33
    1/22/2011 15:34
    3
    1/22/2011 15:35
    1/22/2011 15:36
    Required 
    starttime_s1
    endtime_s1
    starttime__s2
    endtime_s2
    starttime_s3
    endtime_s3
    1/22/2011 15:31
    1/22/2011 15:32
    1/22/2011 15:33
    1/22/2011 15:34
    1/22/2011 15:35
    1/22/2011 15:36

    What is it that you're trying to accomplish with this?
    The reason I ask is that pivoting data is a display function and therefore best left to the application or reporting tier.
    If you're going to insist on "driving screws with a hammer" and really want to do this in SQL, the next question is, Is there a set number of "Stages" that will exist? Is it always going to be 3 stages and only 3 stages?
    If the answer is YES, there will be a fixed number of stages, then it's a simple thing to do with either a PIVOT or CASE statements. (my personal preference is to use case statements, especially if you're pivoting 2 or more columns)
    If the answer is NO, the number is stages can vary... You're left with a Dynamic PIVOT. Dynamic Pivots are a bit more complex to write but there is enough sample code out on the interwebs that you won't have a problem finding the correct syntax. 
    The real problem with a Dynamic Pivot query is the fact that it's pretty much useless. You can't do much (if anything at all) with it... Due to the fact that they have variable numbers of columns, they can't be used in views or procs and I can't think of
    a singe, off the shelf, reporting platform that will allow accommodate data source that has a different number of columns every time it executes... So unless you're going to be content looking at the results in SSMS or developing a custom application, I don't
    see the point.
    Also... Aggregates aren't a problem based on the data you're showing. You only have 1 start time and 1 end time per stage. Using either the MIN or MAX aggregate functions will work to give you the desired result.
    Anyway, hope that helps,
    Jason
    Jason Long

  • How do I create a pivot table in numbers?

    How do I create a pivot table in numbers?

    SO HERE'S WHAT I GOT TO WORK:
    Truth is all the real functionality of categories and pivot tables exists in the formulas. You just have to
    Create a new table with a list of the categories in the header column.
    Add SUMIFS() formula from the browser into the next column.
    Enter your arguments and make sure to check "Preserve Column" for each of them.
    Although it might not be apparent, you can enter multiple test value and condition pairs.
    While I admit the formulas are not nearly so graphic as categories, they are cleaner and less restricting, and they aren't any more difficult to work with than pivot tables.

  • Pivot table without any measure columns

    Hi,
    I have a requirement where all my report columns are from Dimension tables and i have no measure to display in the report.
    But I need to create a Pivot table view for this requirement.
    Can someone help me how to represent results in Pivot Table view without measure columns
    Thanks in Advance.

    Hi Sri,
    Try this it will work.
    Add a dummy column in your measure section.
    then in pivot view --> measure section --> dummy column -->more options -> format heading -->custom css style --> mark use custom css and give display:none
    and
    more options -> format measure values -->custom css style --> mark use custom css and give display:none
    Thanks
    Diney

  • [b]How to create this Custom Table on Custom Schema with foreign key [/b]

    This Custom Table is create in Custom Schema and Refers to Seeded Table in APPS schema
    1 create table test_dff (test_id number(15) primary key,
    2* invoice_id number(15) constraint ap_test_fk REFERENCES ap_invoices_all(invoice_id) ON DELETE CASCADE)
    SQL> /
    invoice_id number(15) constraint ap_test_fk REFERENCES ap_invoices_all(invoice_id) ON DELETE CASCADE
    ERROR at line 2:
    ORA-02270: no matching unique or primary key for this column-list
    How to create this Custom Table on Custom Schema
    thanks in advance

    hi prashant
    sorry for replying late, i have checked your query and it gives me no rows, but if i check for user_cons_columns it gives me no rows either in APPS Schema, but in AP schema it gives me
    SQL> SELECT * FROM user_cons_columns WHERE table_name = 'AP_INVOICES_ALL';
    OWNER CONSTRAINT_NAME TABLE_NAME
    COLUMN_NAME
    POSITION
    AP SYS_C008177 AP_INVOICES_ALL
    INVOICE_ID
    SQL> SELECT constraint_name, constraint_type FROM user_constraints WHERE table_name = 'AP_INVOICES_A
    LL';
    CONSTRAINT_NAME C
    SYS_C008177 C
    SYS_C008178 C
    SYS_C008179 C
    SYS_C008180 C
    SYS_C008181 C
    SYS_C008182 C
    SYS_C008183 C
    SYS_C008184 C
    SYS_C008185 C
    SYS_C008187 C
    SYS_C008189 C
    SYS_C008191 C
    and since this is a combination of Unique and Not Null Constraints , i am getting the same issue. do u have any solution to make the Detail table records to delete without using Alerts/DB Triggers?
    thanks for your time .
    abdul rahman

  • How to create the custom table?

    Hi, how to create the custom table and how to integrate the table with defferent R/3?
    my requiremnt is i have to create the two tables and those i have to integrate with the existed R/3 and using those R/3 i have to update my custom tables .....can give me some idea?
    Tks
    DPk

    how to create the custom table
    There are two approach in creating a table.
    1. Bottom-up approach
    2. Top-down approach.
    Both are valid and you can choose which approach is suitable for you. I always use the bottom-up approach. Here are the steps to create the tables with this approach.
    1. SE11 will take you to the DDIC and enter the name of the new table to be created. Let us say Zname. Click create.
    2. Enter the short discription of the table and enter the field of the table. If it is primary key and you have to check the box.
    3. Enter the data element and double click it, you will be asked to save and will take you to data element discription page. Enter the short discription of the data element and enter the information of domain like the length of field and type of field.
    4. If you wanted to use the existing domain then its fine, or else, you have to create one. Enter the domain name in the data element page and double click it. Page will ask to save and jump to domain creation page.
    5. In the domain page, you have to save the information which you have already given in the data elements page and check it. Before going to data element page, you have to activate the domain.
    6. Go to data element page and save, check and activate.
    7. Go to main table page and save, check, and activate.
    8. Also, you have to save the technical settings of the table.
    The table is now ready for operation. You can use it in your program or you can use it to enter information.
    Check table: It is the table which will have all the information about the Foreign keys which are the primary keys in the check table.
    It can be created by creating the foreign key from the main table. Click foreign key in the main table and it will take you to a page which will ask for table name and field to which foreign key relation has to be associated. Enter the information and you can create the check table automatically.
    SM30 is used for maintenance of the table, that is to realease the errors occured during the creation of the table.
    how to integrate the table with defferent R/3
    Transport the Table to the another server/client/qas/prd
    Kanagaraja L

  • How to Create Event polling table

    hi,
    1)How to Create Event polling table
    2) wahts RPD stands for.
    3) when we are prefer Dynamic variables.
    thanks.
    raj

    1) http://obiee101.blogspot.com/2008/07/obiee-managing-cache-emptyingpurging.html
    2) Repository Project Design ?
    - More than likely the extension RPD was not used by anything else when Siebel Analytics first started using it, no doubt the 'RP' is repository, so use 'Definition' or 'Design' as you like. Im pretty sure there is nothing in the documentation but i've not checked, maybe you could check and let us know?
    3) Dynamic variables would be something like 'CURRENT_MONTH' where the same query does not need to fire per user (ie SESSION variable) but needs to be periodically refreshed. Another use of you dynamic variable might be 'LAST_ETL_DATE' or somethng similar which might implement with your event polling table. By including the Variable within a Business Model, all cache for the Business Model is purged whenever the Variable's value changes.

  • How to create a temp table in the memory, not in disk?

    in sql server, you can create a temp table in the memory instead of disk,
    then you can do the insert, delete,update and select on it.
    after finishing, just release it.
    in Oracle,
    I am wonderfing how to create a temp table in the memory, not in disk?
    thanks,

    Thanks for rectifying me Howard.
    I just read your full article on this too and its very well explained here:
    http://www.dizwell.com/prod/node/357
    Few lines from your article
    It is true, of course, that since Version 8.0 Oracle has provided the ability to create a Keep Pool in the Buffer Cache, which certainly sounds like it can do the job... especially since that word 'keep' is used again. But a keep pool is merely a segregated part of the buffer cache, into which you direct blocks from particular tables (by creating them, or altering them, with the BUFFER POOL KEEP clause). So you can tuck the blocks from such tables out of the way, into their own part of the buffer cache... but that is not the same thing as guaranteeing they'll stay there. If you over-populate the Keep Pool, then its LRU mechanism will kick in and age its contents out just as efficiently as an unsegregated buffer cache would.
    Functionally, therefore, there can be no guarantees. The best you can do is create a sufficiently large Keep Pool, and then choose the tables that will use it with care such that they don’t swamp themselves, and start causing each other to age out back to disk.
    Thanks and Regards

  • Creating a Pivot Table in a XML publishe

    When creating a Pivot Table in a XML publisher in Word, is there a way for a Pivot table to respect the fact that it's inside of a group function? I'm looping over site , and within each site I want to create a Pivot Table that has Months going across and SUB inventories going down, but only for that site.

    Hello,
    create one column in criteria and change it's fx to case when 1=0 then Products."Prod Name" else 'Tota Loanl' end
    Now go to pivot and drag this column to Columns block of pivot. But keep this column up of Measure Labels and Now, go to column Format values.
    Mention cell horizontal alignment to Center
    see the following screenshot, Header is the column i created with the above functionality.
    !http://i852.photobucket.com/albums/ab83/kishorg86/Header.jpg!

  • How to create variant for table/view ?

    Hi,
    When I go through SM30, I find a radio button called variant. I don't know the effect.
    Can anyone tell me how to create variant for table / view ?
    I want to know when we need to create variant for table/view.
    Best regards,
    Chris Gu

    hi ,
    Whenever you start a program in which selection screens are defined, the system displays a set of input fields for database-specific and program-specific selections. To select a certain set of data, you enter an appropriate range of values.
    For further information about selection screens, refer to Selection Screens in the ABAP User's Guide.
    If you often run the same program with the same set of selections (for example, to create a monthly statistical report), you can save the values in a selection set called a variant
    Procedure
    To create a new variant:
           1.      On the ABAP Editor initial screen, enter the name of the program for which you want to create a variant, select Variants, and choose Change.
           2.      On the variant maintenance initial screen, enter the name of the variant to be created.
    Note the naming convention for variants (see below).
           3.      Choose Create.
    If the program has more than one selection screen, a dialog box for screen assignment appears. The dialog box does not appear if the program only has one selection screen. The selection screen appears in this case.
           4.      If there is more than one selection screen, select the screens for which you want to create the variant
    5.      Choose Continue.
    The (first) selection screen for the report appears.
    If your program has more than one selection screen, use the scroll buttons in the left-hand corner of the application toolbar to navigate between them and to fill the fields with values. If you keep scrolling forwards, the Continue button appears on the last selection screen.
           6.      Enter the desired selection values, including multiple selection and dynamic selection.
           7.      Choose Continue.

Maybe you are looking for

  • Shift-Tab Keyboard Shortcut not working

    For some reason, my Shift-Tab keyboard shortcut is not work in TextEdit, PowerPoint, and NeoOffice. Has anyone else run into this problem? It's very annoying having to deal with Bulleted lists and setting the proper indentation! I did a clean install

  • Can Rev A Air Owners give some feedback on Garageband use?

    Hi I think it's much better to rephrase the question like this: If you have a Rev A Macbook Air please can you tell me how Garageband functions, using up to 8 tracks of software intruments and perhaps recording in 1 track of audio. Can it cope with u

  • Beginners CSS layout question - expanding a layer and not overlapping another

    Having got well and truly fed up of using tables to layout pages I am trying to gem up on CSS layer based layout. All well and good but despite the various tutorials I can't find an answer to this question... Q. I have a layout with layers to make a

  • Check for Oracle Service using a batch

    Hi, I am using Oracle XE 10g as the database for my project. I have a custom service to be started only if Oracle service is up and running. Currently i am checking for the service as below: +:WHILELOOP+ net start | find /i "oracleservicexe" >nul IF

  • Vendor address replication

    Hi all, I created a vendor on ECC system and in Purchase Organization Data I inserted two different addresses (one for vendor, one for purchase order vendor with partner role). When I replicate it to SRM(BBPGETVD txn), in SRM Business Partner data, I