How to define a dynamic column to count the quarter of each year?
Lets see the result that now displayed:
YEARS MONTHS SUMMONTH SUMYEAR SUMQUARTER
2009 Jan 127994 1766166 449652
2009 Feb 168106 1766166 449652
2009 Mar 153552 1766166 449652
2009 Apr 160329 1766166 438913
2009 May 137605 1766166 438913
2009 Jun 140979 1766166 438913
2009 Jul 148606 1766166 435283
2009 Aug 150390 1766166 435283
2009 Sep 136287 1766166 435283
2009 Oct 149529 1766166 442318
2009 Nov 153268 1766166 442318
2009 Dec 139521 1766166 442318
2010 Jan 124670 1721212 407181
2010 Feb 139278 1721212 407181
2010 Mar 143233 1721212 407181
2010 Apr 149518 1721212 444112
2010 May 152292 1721212 444112
2010 Jun 142302 1721212 444112
2010 Jul 149125 1721212 412855
2010 Aug 130328 1721212 412855
2010 Sep 133402 1721212 412855
2010 Oct 157754 1721212 457064
2010 Nov 137078 1721212 457064
2010 Dec 162232 1721212 457064
The problem is about how to dynamic a new column called "Q_count" to count each displayed row belong to which quarter of year??
In addition, it will repeat again from next year.
For example:
*2009 Jan-Mar will display "q1", Apr-Jun will display "q2".....and for 2010 Jan-Mar, it will display "q1" again and so on.*
Here is my sql that I am using:
select years,months,summonth,sumyear,sumquarter
from(
select years,months,summonth,sumyear,
sum(sumhour) over(partition by years || to_char(ym, 'Q') order by years || to_char(ym, 'Q')) sumquarter,ym
from(
select years, months, days, hours, mins, sumHour, SUM (sumHour) OVER (PARTITION BY years,months,days) sumDay, SUM (sumHour) OVER (PARTITION BY years,months) sumMonth, SUM (sumHour) OVER (PARTITION BY years) sumyear,
to_date(years || months, 'YYYYMon', 'NLS_DATE_LANGUAGE=American') ym
from (SELECT x.years, x.months, x.days, x.hours, x.mins, sum(x.value) as sumHour
FROM xmltest,
XMLTABLE ('$d/cdata/name' passing xmldoc as "d"
COLUMNS
years integer path 'year',
months varchar(3) path 'month',
days varchar(2) path 'day',
hours varchar(2) path 'hour',
mins varchar(2) path 'minute',
value float path 'value'
) as X
group by x.years, x.months, x.days, x.hours, x.mins
order by x.years, x.months, x.days
group by years,months,summonth,sumyear,sumquarter,ym
order by ymThanks everyone helps me!!!
If my understanding is correct..
select years,months,summonth,sumyear,sumquarter,qtr
from(
select years,months,summonth,sumyear,to_char(ym, 'Q') qtr,
sum(sumhour) over(partition by years || to_char(ym, 'Q') order by years || to_char(ym, 'Q')) sumquarter,ym
from(
select years, months, days, hours, mins, sumHour,
SUM (sumHour) OVER (PARTITION BY years,months,days) sumDay,
SUM (sumHour) OVER (PARTITION BY years,months) sumMonth,
SUM (sumHour) OVER (PARTITION BY years) sumyear,
to_date(years || months, 'YYYYMon', 'NLS_DATE_LANGUAGE=American') ym
from (
SELECT x.years, x.months, x.days, x.hours, x.mins, sum(x.value) as sumHour
FROM xmltest,
XMLTABLE ('$d/cdata/name' passing xmldoc as "d"
COLUMNS
years integer path 'year',
months varchar(3) path 'month',
days varchar(2) path 'day',
hours varchar(2) path 'hour',
mins varchar(2) path 'minute',
value float path 'value'
) as X
group by x.years, x.months, x.days, x.hours, x.mins
order by x.years, x.months, x.days
order by ymEdited by: jeneesh on Mar 26, 2012 5:49 PM
Removed unnecessary GROUP BY
Similar Messages
-
Newbie: how to create a dynamic select list of the current date + 5 years
Hi - I'm a JSP newbie (coming from a PHP background), and am trying to create a select list that contains the current year, plus 5 years. So, the list when generated (today), would display:
2007
2008
2009
2010
2011
2012
Obviously, the code would need to generate inside the option tags, as well as in the value property of the option tag.function addit(){
var val = 2012; //you can take this from js date object and strip it off
for (var i=2007; i <= val;++i){
addOption(document.getElementById("mycombo"), i, i);
function addOption(selectbox,text,value)
var optn = document.createElement("OPTION");
optn.text = text;
optn.value = value;
selectbox.options.add(optn);
}without hardcoding:
function addit(){
var dd = new Date();
var yearnow = dd.getFullYear();
for (var i=yearnow; i <= yearnow + 5 ;++i){
addOption(document.getElementById("mycombo"), i, i);
function addOption(selectbox,text,value)
var optn = document.createElement("OPTION");
optn.text = text;
optn.value = value;
selectbox.options.add(optn);
in your jsp:
<body onload="addit();">
<form>
<select name="mycombo">
<option> Select year</option>
</select>
</form>
</body>
Message was edited by:
skp71
Message was edited by:
skp71 -
How can we get Dynamic columns and data with RTF Templates in BI Publisher
How can we get Dynamic columns and data with RTf Templates.
My requirement is :
create table xxinv_item_pei_taginfo(item_id number,
Organization_id number,
item varchar2(4000),
record_type varchar2(4000),
record_value CLOB,
State varchar2(4000));
insert into xxinv_item_pei_taginfo values( 493991 ,224, '1265-D30', 'USES','fever','TX');
insert into xxinv_item_pei_taginfo values( 493991 ,224, '1265-D30', 'HOW TO USE','one tablet daily','TX');
insert into xxinv_item_pei_taginfo values( 493991 ,224, '1265-D30', 'SIDE EFFECTS','XYZ','TX');
insert into xxinv_item_pei_taginfo values( 493991 ,224, '1265-D30', 'DRUG INTERACTION','ABC','TX');
insert into xxinv_item_pei_taginfo values( 493991 ,224, '1265-D30', 'OVERDOSE','Go and see doctor','TX');
insert into xxinv_item_pei_taginfo values( 493991 ,224, '1265-D30', 'NOTES','Take after meal','TX');
select * from xxinv_item_pei_taginfo;
Item id Org Id Item Record_type Record_value State
493991 224 1265-D30 USES fever TX
493991 224 1265-D30 HOW TO USE one tablet daily TX
493991 224 1265-D30 SIDE EFFECTS XYZ TX
493991 224 1265-D30 DRUG INTERACTION ABC TX
493991 224 1265-D30 OVERDOSE Go and see doctor TX
493991 224 1265-D30 NOTES Take after meal TX
Above is my data
I have to fetch the record_type from a lookup where I can have any of the record type, sometime USES, HOW TO USE, SIDE EFFECTS and sometimes some other set of record types
In my report I have to get these record typpes as field name dynamically whichever is available in that lookup and record values against them.
its a BI Publisher report.
please suggestif you have data in db then you can create xml with needed structure
and so you can create bip report
do you have errors or .... ? -
How to define dependancy between sowtware comps in the SLD
how to define dependancy between sowtware comps in the SLD,
i have a software comp, in the IR, where i import all RFCs and IDOCs, so that they can be used across all software comps in the IR,
since, IDOCs imported in one software comp, cant be used in another s/w comp,
i need to create that dependancy..............................
how can i mention the dependancy in the SLD....Hi,
Please read the Rules OF Engagement,
https://www.sdn.sap.com/irj/sdn/wiki?path=/display/home/rulesofEngagement&
<i>
Do not use words in capital letters and any of the words: urgent, quickly, burning, etc in your message. Especially not in the title! This just irritates and does not help you get to your goal. From our side, we definitely do not answer faster when we see these words.
The same goes for such things as ??? or !!! in appends. In the English language one ? or ! is sufficient to terminate a sentence. </i>
Answering you question, Say you have 2 SWCV's. SWCV A and B. All objects imported in SWCV A should be visible in B. In this case, go to SWCV B and in this, Go to the Dependency Tab , and Select SWCV A here as the dependent Component.
In your IR, Clear SLD Cache and Reimport the 2 SWCV's into the IR and now you will see the Basis Objects in SWCV B. All the existing objects will not be affected as a result of this reimport into IR.
Regards
Bhavesh -
A column that counts the records......need some help
say i have a table with values {a, b, c, d, f};
i want a column that counts the rows of these records with out putting the value manually.
COL1 COL2
0 a
1 b
2 c
3 d
4 f
I have created a data block (wizard) for inserting the values into the table. But i want it to insert the values in COL1 automatically. Seems easy but i dont seem to be able to figure this out...with tab1 as
(select 'a' col2 from dual
union all
select 'b' col2 from dual
union all
select 'c' col2 from dual
union all
select 'd' col2 from dual
union all
select 'f' col2 from dual
-- End of test data
select rownum - 1 col1, col2 from
(select col2 from tab1 order by col2)
COL1 COL2
0 a
1 b
2 c
3 d
4 f Regards
Dmytro -
In VIEWING (to print) my iTunes music (in finder), how can i view subfolders without clicking on the triangle of each main folder?
I am trying to print a list of all my music. For example, main folder is BEATLES. Subfolders are Magical Mystery Tour, Yellow Submarine, Abbey Road, etc...
and I want to view and print all the subfolders. This is a recovery project after my hard drive failed. I know this is truly a "finder" question and will double post there.
Thanks.
Amyamy lynn wrote:
way too much ink.
Don't know what this means but okay. -
How to change recordset bahaviour to accept dynamic column names in the where clause
Hi
im using php-mysql and i make a recordset and i want to make the column names in the where clause to be dynamic like
"select id,name from mytable where $tablename-$myvar";
but when i do this my i break the recordset and it disappear
and when i use variables from advanced recordset it only dynamic for the value of the column not for the column name
and when i write the column name to dynamic as above by hand it truns a red exclamation mark on the server behaviour panel
so i think the only way is to change the recordset behaviour is it? if so How to make it accept dynamic column names?
thanks in advance.As bregent has already explained to you, customizing the recordset code will result in Dreamweaver no longer recognizing the server behavior. This isn't a problem, but it does mean that you need to lay out your dynamic text with the Bindings panel before making any changes. Once you have changed the recordset code, the Bindings panel will no longer recognize the recordset fields.
Using a variable to choose a column name is quite simple, but you need to take some security measures to ensure that the value passed through the query string isn't attempting SQL injection. An effective way of doing this is to create an array of acceptable column names, and check that the value matches.
// create array of acceptable values
$valid = array('column_name1', 'column_name2', 'column_name3');
// if the query string contains an acceptable column name, use it
if (isset($_GET['colname']) && in_array($_GET['colname'], $valid)) {
$col = $GET['colname'];
} else {
// set a default value if the submitted one was invalid
$col = 'column_name1'
You can then use $col directly in the SQL query. -
How to Define a Dynamic Barcode on a PDF Page?
I have a situation where we have a PDF form with multiple rows, (rows can be added as per the user's requirement), means user can click AddRow button and pdf will generate a new row to fill the data. There is no max limit of the rows, it vary and can be anywhere from row 1..10, 1..100, or 1..50 and so on.....
The first pice of the form is to create table/row with Add Row button has been completed. I have already added the AddRow button functionality into the form, but we also need to point the row's data to the barcode. Each data row should point to a single barcode 1 to 1 bases (One row one barcode). How to implement and design the barcode so that each row will be handled dynamically with one barcode? Or, if there is any better approach to handle this.
I would really appreciate if you could send any document, example or sample.
Thanks!Consider the following scenario:
if you have defined a table and made a Cell in the table contain a TextField and it repeats, the SOM expression would look this
form1.Table1.Row1.TextField1[0] (Cell1 of Row1) as an example.
This instance of TextField[0] can be captured in the barcode Collection via the collection UI, but there is no way through the UI to get form1.Table1.Row1.TextField[1] (second instance) included in the barcode data.
I would check this blog entry out if you are interested in capturing values for repeating objects in a barcode, such as you might find in a dynamic table of a dynamic form:
http://blogs.adobe.com/formfeed/2010/02/paperforms_2d_barcodes_with_re.html -
How to generate a dynamic column with unique value in AMDP
Hi Collegue,
For AMDP I have a table with material plant,i have to assign a unique number to each unique combination of material,plants into a dynamic column say sequence.
Please suggest me how to proceed.
Regards,
Saurabhhi
Firstly, have a look at the following code to see how this can be implemented -
REPORT ZTEST.
perform test.
class test definition.
public section.
methods: create_screen.
endclass.
class test implementation.
method create_screen.
data: report_line(72),
report_source like table of report_line.
data: err_message(240),
err_line type i,
err_word(100).
report_line = 'REPORT TEST.'.
append report_line to report_source.
report_line = 'PARAMETERS: P_TEST TYPE I.'.
append report_line to report_source.
report_line = 'START-OF-SELECTION.'.
append report_line to report_source.
report_line = 'WRITE : P_TEST.'.
append report_line to report_source.
syntax-check for report_source message err_message
line err_line
word err_word.
if err_message is initial.
INSERT REPORT 'ZZZTESTZZZ' FROM REPORT_SOURCE.
SUBMIT ZZZTESTZZZ VIA SELECTION-SCREEN AND RETURN.
endif.
endmethod.
endclass.
form test.
data test type ref to test.
CREATE OBJECT TEST.
call method test->create_screen.
endform.
As you can see, the report is being written dynamically. Once the INSERT REPORT statement is executed, the program is available. you can you external subroutine calls to pass the data between the programs now.
Regards,
ravish
<b>plz dont forget to reward points if helpful</b> -
Hello,
I am doing a project that uses MS Access to access data about a baseball team . The MS Access Database provides the names, addresses, and age of the players. All the players are 12, 13, or 14 years old. I need to display the average age for the team on a
label, which was easy. The problem is that I also have to display the number of players who are 12, 13, and 14 years old and I have no idea how to do that.
Here is my code so far:
Public Class frmBaseball
Private Sub TeamBindingNavigatorSaveItem_Click(sender As Object, e As EventArgs) Handles TeamBindingNavigatorSaveItem.Click
Me.Validate()
Me.TeamBindingSource.EndEdit()
Me.TableAdapterManager.UpdateAll(Me.LittleLeagueDataSet)
End Sub
Private Sub frmBaseball_Load(sender As Object, e As EventArgs) Handles MyBase.Load
'TODO: This line of code loads data into the 'LittleLeagueDataSet.Team' table. You can move, or remove it, as needed.
Me.TeamTableAdapter.Fill(Me.LittleLeagueDataSet.Team)
End Sub
Private Sub btnAges_Click(sender As Object, e As EventArgs) Handles btnAges.Click
Dim strSql As String = "SELECT * FROM Team"
Dim strPath As String = "Provider=Microsoft.ACE.OLEDB.12.0 ;" & "Data Source=e:\LittleLeague.accdb"
Dim odaTeam As New OleDb.OleDbDataAdapter(strSql, strPath)
Dim datAge As New DataTable
Dim intCount As Integer = 0
Dim intTotalAge As Integer
Dim decAverageAge As Decimal
odaTeam.Fill(datAge)
odaTeam.Dispose()
For intCount = 0 To datAge.Rows.Count - 1
intTotalAge += Convert.ToInt32(datAge.Rows(intCount)("Age"))
decAverageAge = Convert.ToDecimal(intTotalAge / datAge.Rows.Count)
Next
lblAverage.Visible = True
lblAverage.Text = "The average age of the team is " & decAverageAge.ToString("N2")
lbl12.Text = "The number of 12 year olds is "
lbl13.Text = "The number of 13 year olds is "
lbl14.Text = "The number of 14 year olds is "
lbl12.Visible = True
lbl13.Visible = True
lbl14.Visible = True
End Sub
End Class
I think I should use a For..Next loop but I don't know how to identify and match using this database, and then count how many repeated 12, 13, 14 years old there are.
Any help would be really appreciated.Hello,
Conceptually speaking you would group the data and count. Beings this is school work the demo below is a static example and not suitable for your assignment, its to show a point. Now if you have learned about LINQ and Lambda this logic can apply to your
question but need to work out using this your data which can be done. If not look at using SQL Grouping.
Example of SQL grouping and count
select country, count(country) as count from customers group by country
Module Module1
Public Sub GroupingDemo()
Dim dt As DataTable = SimulateLoadFromDatabase()
Dim TeamData = dt.AsEnumerable.GroupBy(
Function(student) student.Field(Of Integer)("Age")) _
.Select(Function(group) New With
Key .Value = group.Key,
Key .Info = group.OrderByDescending(
Function(x) x.Field(Of String)("Name"))}) _
.OrderBy(
Function(group) group.Info.First.Field(Of Integer)("age"))
Dim dictData As New Dictionary(Of String, String)
For Each group In TeamData
Console.WriteLine("Group: {0} count: {1} ", group.Value, group.Info.Count)
dictData.Add(group.Value.ToString, group.Info.Count.ToString)
' The following is not needed but good to show
For Each item In group.Info
Console.WriteLine(" {0} {1}",
item.Field(Of Integer)("Identifier"),
item.Field(Of String)("Name"))
Next
Next group
Console.WriteLine()
Console.WriteLine("This data can be used to populate control text")
For Each Item As KeyValuePair(Of String, String) In dictData
Console.WriteLine("{0} {1}", Item.Key, Item.Value)
Next
End Sub
Private Function SimulateLoadFromDatabase() As DataTable
Dim dt As New DataTable With {.TableName = "MyTable"}
dt.Columns.Add(New DataColumn With {.ColumnName = "Identifier", .DataType = GetType(Int32),
.AutoIncrement = True, .AutoIncrementSeed = 1})
dt.Columns.Add(New DataColumn With {.ColumnName = "Name", .DataType = GetType(String)})
dt.Columns.Add(New DataColumn With {.ColumnName = "Age", .DataType = GetType(Int32)})
dt.Rows.Add(New Object() {Nothing, "Bill", 13})
dt.Rows.Add(New Object() {Nothing, "Karen", 14})
dt.Rows.Add(New Object() {Nothing, "Jim", 13})
dt.Rows.Add(New Object() {Nothing, "Paul", 15})
dt.Rows.Add(New Object() {Nothing, "Mike", 14})
dt.Rows.Add(New Object() {Nothing, "Jill", 13})
Return dt
End Function
End Module
Output in the IDE output window
Group: 13 count: 3
3 Jim
6 Jill
1 Bill
Group: 14 count: 2
5 Mike
2 Karen
Group: 15 count: 1
4 Paul
This data can be used to populate control text
13 3
14 2
15 1
Please remember to mark the replies as answers if they help and unmark them if they provide no help, this will help others who are looking for solutions to the same or similar problem. -
How to refer to a column name in the domain constraint
When we specify a check constraint (for SQL Server) within a domain we need to enter some syntax expression, for example
len(phone) > 7
Later the modeller will put exactly this expression into SQL code. But this would be wrong as constraint should refer to a column name in the table (which would not be "phone").
So how to make Data modeler to put a real column name within domain constraint?Thank you very much, it really works!
However I would like to know where I can get documentation on such internal variables (like %COLUMN%)? I find it difficult to locate this information in the Help file attached to a modeler (it seems that it only describes UI screens). -
How can I import db column comments into the OBIEE presentation layer?
We have a very well designed data mart - it is a star schema and all the fact and dimension table columns have comments in them with their definition and use. There is virtually no change required in the physical or business layer. The only modifications done in the presentation layer was to hide the Pk/Fk columns.
Is there a way to import these column comments into the presentation layer so that the business user can see this comment in the tool tip while hovering over the presentation column in Answers?
Thanks for your help!Hi,
I assume the comments you mean are stored in user_tab_comments and user_col_comments.
When this is the case you should do the following:
Go to your subject area in your presentation layer. For now I assume the name of this subject area is "Subject Area".
Then right click on this subject area and check "Externalize Descriptions".
Then create an initialization block (session) using this query:
(select 'CD_Subject_Area_' || table_name, comments from user_tab_comments)
union all
(select 'CD_Subject_Area_' || table_name || '_' || column_name, comments from user_col_comments)
Use "Row-wise initialization" for this initialization block.
Two comments:
1) Like I said, I assume Subject Area is the name of your subject area in your presentation layer, so I guess you need to replace this with the name of your Subject Area.
But be sure that you replace each space ' ' with an underscore '_'.
2) Maybe you need to refine above querys by filtering on table_name for those table_names you are using.
Good luck.
Regards,
Stijn -
How can I add a column to show the website (web site) of an rss feed?
I've got a lot of rss feeds coming into thunderbird. I organized some into folders, but also have a folder for several rss feeds as they adress the same topics and I prefer not to browse through 25 separate folders. However, the sender doesn't always make it clear which blog it's from, so I'd like to add a column which shows the website of the rss feed. (sender is often: [email protected], and there are different writers for a single blog who themselve have their own blog as well, so can't sort on sender name either).
When opening an rss feed, it displays in the header: web site (with the space) and then the web adress. This is what I'd like to be able to see in my columns.
I didn't see an option yet to customize columns, nor did I find an addon that does this.
Does anyone know a solution?Thanks, that seems to work. I'm struggling to place the lightbox at the top of the page however - when I click the trigger I want the menu image to display anchored to the top of the page, but there's always a gap as it centers the image. Help is appreciated!
-
Javascript Question - How to Insert a Dynamic/Current Date into the Footer of a Scanned Document
Hi!
I am looking for help in finding a Javascript that would allow the insertion of a dynamic/current date into the footer of a scanned document at the time the document is printed.
I am currently using Adobe Acrobat Professional 8.0 at my work and there has arisen a need to have a dynamic/current date in the footer on scanned documents when they are printed out on different days by different people.
I am new to the Forum and I am also very new to Javascript and what this entails.
Thank you in advance for your help and input!
Tracythis.addWatermarkFromText({
cText: util.printd("mmmm dd, yyyy", new Date()),
nTextAlign: app.constants.align.right,
nHorizAlign: app.constants.align.right,
nVertAlign: app.constants.align.bottom,
nHorizValue: -72, nVertValue: 72
Will insert the current Monday/Day/Year as a text watermark at the bottom of every page of a document, 1 inch up and 1 inch in from the right corner. -
I created a birthday calendar to use in iphoto for calendar. When a new calendar project is started each year, I click on it in. Some how the birthday did not populate the photo calendar this year. The photo calendar is almost complete. Is there a way to add the birthday iCal calendar into the calendar project? I would prefer not to start over.
Hi,
If you first select the calendar on the left, so that its background is highlighted blue/grey, when you make a new events they should be added to that calendar.
Best wishes
John M
Maybe you are looking for
-
hai gurus, I tried to cancel excise document in J1IJ but when i went to the tab and selected cancel selection the system is popping up a message: Rg23dselected qntyis than goods issue qnty.. hw to solve it? with regards
-
Upload Project Structure or Roadmap from MS Project to solution manager
I have a project ready in MS Project . I want to make a roadmap out of it. How is that possible? Do I have to manually edit roadmap structure? OR Is it possible to upload Project Structure or Roadmap from MS Project to solution manager?
-
German iPhone 5 in U.S.
Can our exchange student use her German iPhone 5 here in Minnesota? What do we need to do to make that happen?
-
I HATE IOS 7. ever since i downloaded it, my phone crashes ALL THE TIME.
Does ANYONE else have this problem? It's a new phone because I sent it in and they sent me a refurbished one. But it keeps crashing ever since i downloaded ios 7. I hate ios 7. I know you cant downgrade but is there anybody that can get around it? Ev
-
DCIteratorBinding reset when using go link
When I use a go link to step to another page in my application the DCIteratorBinding on the new page is always reset (I think the query is always automatically executed). This does not happen when using a control flow case. It's a very basic item, so