Conditional summary rows
HI,
I have a table which contains of data about users entering games.
game_id (int) | user_id (int) | entry_created (datetime)
I need to create a query which displays how many users entered certain times in a particular game. E.g. for game_id=1
Nr_of entries | Nr_of_users
1 15
2 8
3 7
4 etc.
5
6
7
8
9
10
10+
20+
50+
100+
500+
It means that 15 users entered once, 8 users twice, 7 users 3 times, etc.
The list has to be dynamic, that is if there are no users with 50+ entries then the remaining rows should not be generated. I use 2008.
Thanks.
P.
Hi Pelso,
According to your description, you want to count the number of users based on entries. Right?
In this scenario, we can use Case .... When condition to name each kind of entries as sub query, then use count() to get numbers. Use the query below:
select NumberOfEntries as 'Nr_of entries',COUNT(Game_id) as 'Nr_of users'
from
select
case
when entries=1 then '1'
when entries=2 then '2'
when entries=3 then '3'
when entries=4 then '4'
when entries=5 then '5'
when entries=6 then '6'
when entries=7 then '7'
when entries=8 then '8'
when entries=9 then '9'
when entries=10 then '10'
when entries>10 and entries<20 then '10+'
when entries>=20 and entries<50 then '20+'
when entries>=50 and entries<100 then '50+'
when entries>=100 and entries<200 then '100+'
when entries>=200 and entries<500 then '500+'
when entries>=500 then '500+'
else 'other'
end
as NumberOfEntries,Game_id
from
select Game_id,COUNT(entry_created) as entries from #t group by Game_id
group by NumberOfEntries
If you have any question, please feel free to ask.
Best Regards,
Simon Hou
Similar Messages
-
How can i create a grid with summary row
Hello Professionals,
I'm wondering how could i create a grid like the grid below, i want to create a grid with summary row,
i have tried to create it using collapsing but it didn't work as required.
Any suggestions?, i want to know just the starting point so i can make deep investigations.
Thanks in Advance,Hi Karem,
this can be achieved by just assigning a datatable containing the data plus some formatting of grid. Meaning there is no feature for that.
The datatable can be filled manually or by sql query. Then you have to attach some events for updating the values ( validate after for gid item ).
A small example for a sql query showing last month quotations and orders with summary :
select 1 as Sort,cast(DocNum as varchar) as DocNum,DocTotal,convert(varchar, DocDate,104) from OQUT where DocDate between DATEADD(month, -1, GETDATE()) AND GETDATE()
UNION ALL
Select 2 as Sort,'Summary ( Quotation ) : ',sum(DocTotal), convert(varchar, DATEADD(month, -1, GETDATE()),104)+' - '+convert(varchar, GETDATE(),104) from OQUT where DocDate between DATEADD(month, -1, GETDATE()) AND GETDATE()
UNION ALL
select 3 as Sort,cast(DocNum as varchar) as DocNum,DocTotal,convert(varchar, DocDate,104) from ORDR where DocDate between DATEADD(month, -1, GETDATE()) AND GETDATE()
UNION ALL
Select 4 as Sort,'Summary ( Order ) : ',sum(DocTotal), convert(varchar, DATEADD(month, -1, GETDATE()),104)+' - '+convert(varchar, GETDATE(),104) from ORDR where DocDate between DATEADD(month, -1, GETDATE()) AND GETDATE()
ORDER by Sort
regards,
Maik -
Using Previous function in summary rows?
Hi,
I have a requirment, where I have to use the value got in previous column in the summary row.
The scenario is as follows.
There are Product, Quantity on Hand , Order Type and Date column. I am using cross tab, As I have to use the details of columns for each date.
So date will be spreaded across table as there are more dates.
In summary column, I would like to do a calcuation for each date. And I should use the calculated amount on one date in the next date and the calcuation continues.
I am trying to use previous function, but its showing computation error.
I am attaching a excel sheet with a sample example for easy understanding.
The calculation which I used in summary row is avialble in formula section, when we select the column.
Thanks in Advance.
Regards
GowthamHi BOCP,
Yes, I am trying to use this function in Summary after Break.
Sorry, I missed out attachment. And I didn't find a way to attach it.
Suresh,
I didn't find last() function in WebI Editor. I am using BO XI R2.
Thanks a lot.
Regards,
Gowtham Sen. -
hi,
( A Financial Report consisting of Account wise detail record printing followed by summary column on debit and credit entries. The requirement is to have one more conditional summary column of the same data at the end of the above summary column.)
I have single query which has join condition and with two groups, G1,G2, one of the group gives master records (G1)and the second group(G2) consists of detail records based on master record. the first group(G!) consists of fields like Date,Account,OpeningBalance,description.
and the second group (G2)consists of DebitAmount,CreditAmount ,voucherno etc
The first group fields are placed in repeating Frame R1 and second group fields are placed in second repeating Frame R2 which itself is with the first Repeating Frame ie R1 And summary columns are also placed in group G1 and repeating frame R1 for debit and credit fields.
I want the summary of conditional Detail Records, suppose there are 10 detail records for one master Record, of which i want the summary of those detail records which are cash payment(ie I want to use summary for detail records on condition), As I want the total of Debit and Credit for every master record so i placed that field (which has to show the total) in first group G1 and Repeating Frame R1. How do i solve this problem.
I did try to write a query in Formula column in group G1 but it's taking lot of time as i have 1400 pages Report.
I am getting the report correctly but I only need to show the total of detail records on condition.
For any further clarification you can contact me.
Thanks in advance
RamaTo apply filter condition for a dynamic parameter you need to create a command using "Add Command" in database expert.
Now write the command like
select company from table where (use condition here)
click on ok and remove the links between the command ang existing tables.
Now create a dynamic parameter in the report and use company field from command instead of using for existing table. This shows you the data according the the fileter condition added in add command.
Regards,
Raghavendra -
Tabular form calculated summary row
Hopefully this may be a quick question with either a yes or a no
I have a tabular form with columns
Project Name , Wk1 , Wk2 , Wk3 etc ,
basically so PM's can track the hours against a project
I have used the sum checkboxes to create a summary row
but they also want a row that calculates how many hours remaining for each week under the week no cols , obviously subtracted ffrom the hours budget for each week assigned to the project and person
I've done the summary and calculation in a view but this isn't acceptable as a UNION query in a tabular form
I've also tried another region under the Tabular form but as the project name is a variable length its not easy keeping the Wk cols aligned
thanks in advance
ChrisHi Gus/Paul,
I had the same requirements as you, resulting from the fact that newly added rows may not be visible to the user until he/she has scrolled down sufficiently, but, by lowering my standards (something I excel at :D ), I was able to find an acceptable compromise.
As you probably noticed yourselves, when you "edit" the ADD button, you can see that a call is made to the addRow() javascript function. I therefore took a look at the javascript code - foolish really as I am an oracle DBA from the Jurassic period. Needless to say it scared the pants off me... So, fuelled by cowardice, I snatched at an inferior-but-dead-easy-to-implement alternative solution whereby the page is automatically "scrolled" to the bottom of the form when the "ADD" button is clicked.
Should this "cop out" work for you, you can implement it in the following way:
1. Create a new HTML region immediately after the tabular form, containing the following source: <font color="blue"><a name="bottom_of_page"></a></font>
2. Amend the action when the "ADD" button is clicked to scroll down to the new region by doing the following:
- edit "ADD" button
- Go to "Action when button Clicked" section
- Amend "URL Target" from
<font color="blue">Javascript:addRow();</font>
<br>to
<font color="blue">Javascript:addRow();window.location='#bottom_of_page'</font>
<br>
<br>Regards,
Amr. -
Adding a dynamic summary row for a spark data grid
i'm looking for a solution for a spark data grid.
by clicking on a row it will become larger and will show under the original row a some kind of a summary text with no realtion to columns.
is there a summary row option for a spark datagrid that can shown by clicking on the row?Why would you need to make this part of the DataGrid? Just create some kind of view and bind it's data to the selectedItem of the DataGrid.
*edit*
Ohhhh, I see that you want it to display under the item. I believe you can do what you need in the skin, but I haven't had a chance to use the spark DataGrid yet so I can't say for sure. I know it has a feature to skin the selection, so I'm sure you can use that to do what you need. -
I have created a JTable with some information. I want to have the last row of the table as a summary row so I want it to stand out. How would I go about putting the text in the last row of the table in bold font?
Thanks for help!I looked at this example, but I thought that while the structure of the tutorial is good, the code might not be so great. Take for example the number renderer class, I won't repeat it here (might violate copyright) but the setValue method gets a number instance each time it is invoked to render a cell. My understanding is that this is inefficient, as getting an instance is a fairly involved procedure (it involves looking up locale information for instance). Also the code makes heap allocations which could potentially overwhelm the garbage collector (from what I've read).
I'm learning java, and I used the example to make a decimal renderer. The main purpose of this is to show the number for the default locale and the specified number of decimal places:
import java.text.NumberFormat;
import java.text.DecimalFormat;
import javax.swing.table.DefaultTableCellRenderer;
public class DecimalRenderer extends DefaultTableCellRenderer {
int precision = 0; //my addition
Number numberValue; //moved from setValue()
NumberFormat nf; //moved from setValue()
public DecimalRenderer(int p_precision) {
super(); //same as example
setHorizontalAlignment(javax.swing.SwingConstants.RIGHT); //same as example
precision = p_precision; //my addition
nf = NumberFormat.getNumberInstance(); // moved from setValue
nf.setMinimumFractionDigits(p_precision); // my addition
nf.setMaximumFractionDigits(p_precision); // my addition
public void setValue(Object value) {
if ((value != null) && (value instanceof Number)) {
numberValue = (Number) value; // re-use the class member, not a local member
value = nf.format(numberValue.doubleValue()); // same as example
super.setValue(value);
} By re-using the number instance and making the variables class level fields as opposed to local members of the setValue function, I expect to avoid the problems I mentioned above.
Have I understood the situation correctly? I guess that experienced people would be aware of this, but I get annoyed by the examples I see as they typically give 'expedient' examples which seldom represent 'best practice'. Often, I can see that something probably isn't best practice, but I don't know what the best practice is. -
Advanced Datagrid - Summary Row without groupping
I need to make a datagrid with a summary row on top of it. It
works fine with the gropping tag inside of groupping collection.
But i don't need groups - i need only summaries.
When I white following code inside of Advanced - flex crashes
and tell something like "cannot null blablala".
quote:
<mx:GroupingCollection id="smallMetricsDataProvider"
source="{bigMetrics}">
<mx:summaries>
<mx:SummaryRow summaryPlacement="first">
<mx:SummaryField dataField="@type" operation="COUNT"
/>
<mx:SummaryField dataField="@budget"
summaryFunction="MetricsUtils.varianceTotalCount" />
<mx:SummaryField dataField="@raw"
summaryFunction="MetricsUtils.varianceTotalCount" />
</mx:SummaryRow>
</mx:summaries>
</mx:GroupingCollection>
What can you advice 4 me?
Thanks, Roman.Fine, I found a way how to do it, using renderprovider 4
folder items with a null height =))).
It's a hack, the bad hack, i hope it wold be improved...
So, i have another problem - i want to get this summary
values. How?
Thanks, Roman. -
In a ADG is it possible to have a pie chart in a summary row?
In a ADG is it possible to have a pie chart in a summary row?
The segments would be worked out from a funtion applied to the data
in that grouping.
Thanks :)The JTable is a tabular component. So it will always have enough columns to display the maximum row length. you don't have to pur a value in every cell.
There are methods in JTable to remove horizontal and vertical lines and you could implement a renderer to make empty cells look like the background.
Cheers
DB -
Summary row in tableview (including sorting and BYPAGE navigation)
Hello everybody,
I already found a few topics dealing with this problem but I wasn't able to find a real solution for this.
So far I'm pretty familiar with table iterators but I have no idea how to handle the summary row to be the last line in a table, even if sorting and navigation by page is allowed in the tableview.
I think you definitely have to add this summary row in your internal table, since you can not add a virtual row in your tableview. And you can custom render this row or respectively each cell for instance with a different color but how to force this row always to appear as the last row in every tableview page (navigation=BYPAGE).
Does anyone have a solution for that?
Thanx
OliverOk, here is what I came up with (hoping I got your problem right):
In your tableview you are displaying <b>x</b> rows, and after these rows you want your sum row to be displayed.
I have done quite some things with iterators, but why not do without one here
Altering the internal table can do as well:
Try to insert a new row after every <b>x</b> rows into your internal table which holds the needed sum values, and then change your tableview to display <b>x+1</b> rows.
In you case you need to do some operations with your internal table (to avoid the sum rows messing up the results) you should somehow "mark" these sum rows so you can distinguish them later on.
Hope this is helpful for your problem.
Max -
Rank only summary rows from group by rollup
I would like to rank only the total rows generated by a group by rollup, but not rank the rows within each group by bucket. Furthermore, I'd like to order by rank in descending order and include the unranked rows within each group.
My query looks something like this:
select customer, month, sum (sell)
from sales
group by rollup (customer, month)
order by customer, month desc nulls first
The results look like:
customer month sum(sell)
<summary rowA> 1,200
custA JAN 100
custA FEB 100
custA MAR 100
custA DEC 100
<summary rowB> 600
custB JAN 50
custB FEB 50
custB MAR 50
custB DEC 50
What I would like to do is:
select dense_rank() over (order by sum(sell) desc <rollup rows only>) as rank,
customer, month, sum (sell)
from sales
group by rollup (customer, month)
order by <summary row rank desc> customer, month desc nulls first
The results would look like:
rank customer month sum(sell)
1 <summary rowA> 1,200
custA JAN 100
custA FEB 100
custA MAR 100
custA DEC 100
2 <summary rowB> 600
custB JAN 50
custB FEB 50
custB MAR 50
custB DEC 50
Any advice?
Thank youLike this?
sql>
select decode(job,null,decode(deptno,null,null,dense_rank() over(order by lst desc)-1),null) rank,
deptno,job,sm
from(
select deptno,job,sm,last_value(sm) over(partition by deptno order by null ) lst
from (
select deptno,job,sum(sal) sm
from emp
group by rollup(deptno,job)));
RANK DEPTNO JOB SM
29025
20 CLERK 1900
20 MANAGER 2975
1 20 10875
20 ANALYST 6000
30 CLERK 950
30 MANAGER 2850
2 30 9400
30 SALESMAN 5600
10 CLERK 1300
10 MANAGER 2450
10 PRESIDENT 5000
3 10 8750 -
Hi
I have a jtable and I want to add a summary row right under the header. I added a row and I specified in the sorting class to start from 1 instead of 0, which made my summary not sortable. but, when I scroll down, the summary row disappears.
How can I make it not disappear? the same problem with printing. I'm using the table.print method and it prints only in the first page, while I want to print on every page.
I think I should add it as part of the header? I have no idea how to do that.
any ideas or help?
Thanks,
Benbak
Message was edited by:
BenbakI think you will find something here: http://www.physci.org/codes/tame/
-
Style AdvancedDataGrid Summary Rows
I have an AdvancedDataGrid with summary rows. Everything works fine, but the user wants the summary rows bolded, so the totals stand out even when the categories are expanded. There don't seem to be any style properties, itemRenderers, or labelFunctions associated with any level of a GroupingCollection. How can I do this?
Thanks.
-JohnI figured it out, so here it is for posterity:
I had to use the AdvancedDataGridColumn's styleFunction, and test the row object for a "GroupLabel" property. If it exists, bold the row, like below:
protected function boldSummaryRows(row:Object, column:AdvancedDataGridColumn):Object {
var styleObject:Object = new Object;
if(row.hasOwnProperty('GroupLabel'))
styleObject.fontWeight = 'bold';
return styleObject; -
I am new to Flex. I wasn't quite sure how to code summary
rows in actionscript. Could some take a look at my codes and help
me figure out why it doesn't work? I really appreciate it.
I need to display a fixed data in group row. That is, I don't
need to calculate the result to be displayed in group row."irislpc" <[email protected]> wrote in
message
news:ghpdmn$s2k$[email protected]..
> If I am not displaying the hierarchical data in
AdvancedDataGrid by using
> group
> collection, can I still use summary rows? I populate the
advanced data
> grid
> with external xml file. The xml is structured
hierarchically so that I
> don't
> need to group the data. The problem is I have data that
need to be
> displayed in
> group row. Can I use summaries function to do that?
> Here is the sample application
>
http://www.irislin.net/itemRenderer/reliability.html
http://livedocs.adobe.com/flex/3/html/help.html?content=advdatagrid_08.html
"Note: Summary data is not supported for hierarchical data
represented by
the HierarchicalData class. You can only create summary data
for data
represented by the GroupingCollection class."
I couldn't get at your app, since I'm not going to upgrade to
Flash Player
10 just to help you (I think that change is far more
difficult to undo than
to do), but you might find that you can make a
GroupingCollection from your
XML just by casting it. -
Customizing summary row AdvancedDatagrid
i want to customise the look and feel of the summaryRow of the AdvancedDatagrid by including borders to the top and the bottom.I tried overriding createChildren() and adding HRule as the first and last child of the summaryRenderer.The HRule is getting added but it is not getting displayed.Am i doing somthing wrong.If so how can i customize the look and feel .Please suggest
You can just use Renderer providers to customize your SummaryRow just like you use Renderer Providers for your columns.Specify the label name of the summary row that you want to customize in the renderer provider.
Maybe you are looking for
-
Problem with SimpleCameraBrowser, can't see Camera
Hi Everyone I download sample: SimpleCameraBrowser and compile it. But when I run it, I found there is no device listed in device browser include my iSight camera. see this screenshot, there is nothinh in device browser (the left part of the window)
-
To display multiple BOMS by selection
I'm trying to avoid havig to create a report to collectively display multiple BOMS by selection (eg MRP controller, group of header materials etc) to satisfy the following: - collective display - multi-level display (indented) - factor scrap, giving
-
In Google Advanced Search, when I click on Search Settings, I go to the drop down box labelled 'Number of Results' and select 100, then click Save Preferences. Until recently Firefox saved my changed settings, but it no longer does so.
-
IMAP accounts locked out - small triangle lock error symbol
I use Apple Mail to read several Gmail IMAP accounts. Mostly, it works fine. I've used Gmail IMAP since IMAP was offered. Every so often, one or more of the accounts will lock out. Apple Mail will display a small upward pointing triangle error symbol
-
I can't run the installer file because a padlock appears in Mac OS X Yosemite.
When I download the file it appears on Finder with a padlock in the upper left corner. If I try to run it, it opens with another program that can't read it. Looking for some information on the internet I read something about the file permissions. But