Listing row length and count of rows
Hi,
I am trying to write a piece of code to fetch number of rows grouped monthly and running out of ideas, please help .. here is my requirement.
I have a flat file which contains table names and I need to query for the date column from those table, group it by month, number rows in that month. The generated output should contain the table_name, month, rowcount, and avg_row_length of that table.
Please advice.
Thanks.
Hi
Good, I understand a lot better now. Sorry, I mis-read your first message.
You need to do some kind of dynamic SQL, that is, you want to run a query like:
select '&table_name'
, to_char(update_date, 'Mon-yyyy')
, count(*) row_count
from &table_name
group by TRUNC (update_date, 'MM')
ORDER BY TRUNC (update_date, 'MM');Does every table have a column called update_date, or is it called by different names in different tables? Either way, you can create a script (let's call it one_table.sql) that accepts an input parameter (the table name), and contains the query above.
Then, to call that for each of your tables, you vould create another script that contains:
-- Adjust SQL*Plus output settings
SET FEEDBACK OFF
SET PAGESIZE 0
SET VERIFY OFF
SPOOL combined_output.lst
-- Write common header line for the whole file
PROMPT table_name Month Rowcount avg_row_len
-- Run query on each table
@@one_table tab1
@@one_table tab2
@@one_table tab3
-- Finished.
SPOOL OFFThis will produce an output file like this:
table_name Month Rowcount avg_row_len
tab1 Jan-2008 20 100
tab1 Feb-2008 30 100
tab1 Mar-2008 40 100
tab2 Jan-2008 20 200
tab2 Feb-2008 50 200If you want to print the table name only on the first row, like this:
table_name Month Rowcount avg_row_len
tab1 Jan-2008 20 100
Feb-2008 30 100
Mar-2008 40 100
tab2 Jan-2008 20 200
Feb-2008 50 200You can make the query in one_table.sql a little more complicated: use ROW_NUMBER or ROWNUM to number the rows, and use CASE to print the table name on row #1, and nothing on the others.
Are you generating the list of tables yourself? If so, then instead of generating just the names, you might generate
@@one_table tab1
@@one_table tab2
@@one_table tab3or even the entire main script.
Sorry, I have to go now. See how far you can get with this, and post again if you have problems.
Similar Messages
-
Dynamic Parameter List questions: Length and Custom Values
I've got a Crystal Report that I want to use Dynamic Values for.
Right now... this report is simply a "SELECT stuff FROM table" SQL query... with a parameter that the report uses to filter.
I use a "Select DISTINCT value from table" to generate a list of values. I put those values into a txt. I then import the text into a static list. This creates a parameter list that is 11 "pages" long on the parameter screen. I also have "custom" values allowed. This is to allow for "new" values and also allow not needing to browse 11 pages for one or two known values.
If I turn the parameter into a Dynamic List based on the same Select statement it stops at 5 pages, obviously cutting off half of the possible values.
Dynamic List also removes the ability to do Custom Values. The filter option wouldn't be a bad alternative BUT it don't work for pages 6+ that aren't there.
How can I remove the 5 page limit (or whatever it is) for Dynamic values?
Thanks
Chris
Edited by: WernerCD on Aug 4, 2010 4:14 PMThere is a limit of 1000 records in dynamic parameters. You can change this by adding a registry value:
registry key : HKEY_CURRENT_USER\SOFTWARE\Business Objects\Suite 11.0\Crystal Reports\DatabaseOptions\LOV
and then add a key called MaxRowsetRecords and give it a value.
if you have Crystal 2008 then the above registry folder will say Suite 12.0. -
Select list with redirect and save the item to insert row
On the Form, I want to select from the item (P105_ADMIN_DOMAIN_ID)
and pop the result on the item (P105_ADMIN_NAME).
P105_ADMIN_DOMAIN_ID define:
Display as "select list with redirect"
Alternate source used "Only when .."
Source Type "Database Column"
Source Value or express "ADMIN_DOMAIN_ID"
P105_ADMIN_NAME define:
Display as "Text Field"
Altrenate source used "Only when .."
Source Type "SQL Query"
Source Value or express "select party
from responsible_party
where logonid
= :P105_ADMIN_DOMAIN_ID"
questions:
1. item P105_ADMIN_DOMAIN_ID DROP DOWN LIST is limited to
some threadhold, it did not list all the value from
the LOV which is follow:
select LOGONID d, LOGONID r
from RESPONSIBLE_PARTY
order by 1
2. I want to insert a row after complete the form.
But my item P105_ADMIN_NAME is defined
Source Type "SQL Query" instead of the 'Database
Column'
How could I overcome these?
Thanks so much for your help.1) what i meant was for you to test this ridiculously huge LOV outside of htmldb, but it occurred to me last night that you could, in fact, be hitting a limit of ours. after some poking around, i have confirmed that. select list items in htmldb are currently limited to 10,000 rows. this was initially done for performance reasons, but they're now opening up the restriction. if you really need to work with that many rows where the user is allowed to pick from a set of values, consider using a popup item type instead. it'd help your app performance as well (in my test cases, it stank to have to wait for my 10k select list rows to come down to my browser).
2) sorry to not have been more clear about this, but when you set your item's "Source Type" back to "Database Column", you'd have to specify that column in the "Source or value expression" field. also, you can't put a sql query into that "Post Calculation Computation" field. as i said before, "you can take a look at the attribute-level help for that field to see implementation examples."
3) stick with "Always..." for now if you're using our auto-dml process(es)
regards,
raj -
List rows with a certain value from a different table?
Hi,
I'm trying to list certain rows from a different table. Similar to the filter feature, kind of like a report.
To be specific, I have 12 tables (Jan-Dec) with many entries each (as rows). Each row has a date, text and further data. Now I want to create an additional table that lists rows from the other tables that have a certain date.
I would like to just enter that date in a header row cell so I can make a quick query. Using LOOKUP only shows the first row of that date. Is that even possible?Hi papalapapp,
If you don't mind using a script, you're using Numbers 3, and all of your monthly tables are on the same sheet, then you could do something like this:
Copy-paste script to Script Editor
Enter date you want to filter on in the designated filterCell (here A1 of the Extract table). Make sure it is formatted exactly like the dates in the monthly tables.
Clear any existing values from the Extract table, and make sure there are enough blank rows.
Click the run button in Script Editor.
SG
property targetTable : "Extract"
property filterCell : "A1"
tell application "Numbers"
tell document 1's active sheet
set dateFilter to table targetTable's cell filterCell's formatted value
--get all data in tables (excluding Extract table)
set vv to {}
repeat with t in tables
if t's name is not targetTable then
set vv to vv & t's rows's cells's formatted value
end if
end repeat
--filter data
set vvFilt to {}
repeat with i from 1 to vv's length
if vv's item i's item 1 is dateFilter then
set vvFilt to vvFilt & {vv's item i}
end if
end repeat
--write filtered data to table
tell table targetTable
repeat with r from 1 to (vvFilt's length)
repeat with c from 1 to vvFilt's item 1's length
set row (r + 1)'s cell c's value to vvFilt's item r's item c
end repeat
end repeat
end tell
end tell
end tell -
How to make an list row Read only
Hi All,
Can anyone please tel me how to make the List row (list item) read only where the status column value is Submit.(i.e the whole row has to be made as readonly, am using event handler to try this out)
Thanks in advanceHi,
According to your description, my understanding is that you want to set the list item read only based on the status column.
If you want to do it using Event Receiver, you need to check the status column value using Server Object Model, then break role Inheritance and rest role assignments to set the item read only.
Here are some detailed code demo for your reference:
Change SharePoint list item permissions to Read only programmatically
How to: Create an Event Receiver
Thanks
Best Regards
TechNet Community Support
Please remember to mark the replies as answers if they help, and unmark the answers if they provide no help. If you have feedback for TechNet Support, contact
[email protected] -
Hi,
I would like to add a Time column (UDF) for pick list rows.
Therefore when ever a row is picked the picked time will display in the row.
Any suggestions.
Thanks,
Kishor
Edited by: Joel on Sep 14, 2009 4:16 PMHi Jordan,
Thank you for the query, but I am getting only the date in the UDF. The UDF I have used is an alphanumeric 30 characters. Is there something else that I would have to do to get the time populated?
Thanks,
Joel -
[Mostly Sorted] Extracting tags - regexp_substr and count help needed!
My original query got sorted, but additional regexp_substr and count help is required further on down!
Hi,
I have a table on a 10.2.0.3 database which contains a clob field (sql_stmt), with contents that look something like:
SELECT <COB_DATE>, col2, .... coln
FROM tab1, tab2, ...., tabn
WHERE tab1.run_id = <RUNID>
AND tab2.other_col = '<OTHER TAG>'(That's a highly simplified sql_stmt example, of course - if they were all that small we'd not be needing a clob field!).
I wanted to extract all the tags from the sql_stmt field for a given row, so I can get my (well not "mine" - I'd never have designed something like this, but hey, it works, sorta, and I'm improving it as and where I can!) pl/sql to replace the tags with the correct values. A tag is anything that's in triangular brackets (eg. <RUNID> from the above example)
So, I did this:
SELECT SUBSTR (sql_stmt,
INSTR (sql_stmt, '<', 1, LEVEL),
INSTR (substr(sql_stmt, INSTR (sql_stmt, '<', 1, LEVEL)), '>', 1, 1)
) tag
FROM export_jobs
WHERE exp_id = p_exp_id
CONNECT BY LEVEL <= (LENGTH (sql_stmt) - LENGTH (REPLACE (sql_stmt, '<')))Which I thought would be fine (having tested it on a text column). However, it runs very poorly against a clob column, for some reason (probably doesn't like the substr, instr, etc on the clob, at a guess) - the waits show "direct path read".
When I cast the sql_stmt as a varchar2 like so:
with my_tab as (select cast(substr(sql_stmt, instr(sql_stmt, '<', 1), instr(sql_stmt, '>', -1) - instr(sql_stmt, '<', 1) + 1) as varchar2(4000)) sql_stmt
from export_jobs
WHERE exp_id = p_exp_id)
SELECT SUBSTR (sql_stmt,
INSTR (sql_stmt, '<', 1, LEVEL),
INSTR (substr(sql_stmt, INSTR (sql_stmt, '<', 1, LEVEL)), '>', 1, 1)
) tag
FROM my_tab
CONNECT BY LEVEL <= (LENGTH (sql_stmt) - LENGTH (REPLACE (sql_stmt, '<')))it runs blisteringly fast in comparison, except when the substr'd sql_stmt is over 4000 chars, of course! Using dbms_lob instr and substr etc doesn't help either.
So, I thought maybe I could find an xml related method, and from this link:get xml node name in loop , I tried:
select t.column_value.getrootelement() node
from (select sql_stmt xml from export_jobs where exp_id = 28) xml,
table (xmlsequence(xml.xml.extract('//*'))) tBut I get this error: ORA-22806: not an object or REF. (It might not be the way to go after all, as it's not proper xml, being as there are no corresponding close tags, but I was trying to think outside the box. I've not needed to use xml stuff before, so I'm a bit clueless about it, really!)
I tried casting sql_stmt into an xmltype, but I got: ORA-22907: invalid CAST to a type that is not a nested table or VARRAY
Is anyone able to suggest a better method of trying to extract my tags from the clob column, please?
Message was edited by:
BoneistI don't know if it may work for you, but I had a similar activity where I defined sql statements with bind variables (:var_name) and then I simply looked for witch variables to bind in that statement through this query.
with x as (
select ':var1
/*a block comment
:varname_dontcatch
select hello, --line comment :var_no
''a string with double quote '''' and a :variable '', --:variable
:var3,
:var2, '':var1'''':varno'',
from dual' as string
from dual
), fil as (
select string,
regexp_replace(string,'(/\*[^*]*\*/)'||'|'||'(--.*)'||'|'||'(''([^'']|(''''))*'')',null) as res
from x
select string,res,
regexp_substr(res,'\:[[:alpha:]]([[:alnum:]]|_)*',1,level)
from fil
connect by regexp_instr(res,'\:[[:alpha:]]([[:alnum:]]|_)*',1,level) > 0
/Or through these procedures
function get_binds(
inp_string in varchar2
) return string_table
deterministic
is
loc_str varchar2(32767);
loc_idx number;
out_tab string_table;
begin
--dbms_output.put_line('cond = '||inp_string);
loc_str := regexp_replace(inp_string,'(/\*[^*]*\*/)'||'|'||'(--.*)'||'|'||'(''([^'']|(''''))*'')',null);
loc_idx := 0;
out_tab := string_table();
--dbms_output.put_line('fcond ='||loc_str);
loop
loc_idx := regexp_instr(loc_str,'\:[[:alpha:]]([[:alnum:]]|_)*',loc_idx+1);
exit when loc_idx = 0;
out_tab.extend;
out_tab(out_tab.last) := regexp_substr(loc_str,'[[:alpha:]]([[:alnum:]]|_)*',loc_idx+1);
end loop;
return out_tab;
end;
function divide_string (
inp_string in varchar2
--,inp_length in number
--return string_table
return dbms_sql.varchar2a
is
inp_length number := 256;
loc_ind_1 pls_integer;
loc_ind_2 pls_integer;
loc_string_length pls_integer;
loc_curr_string varchar2(32767);
--out_tab string_table;
out_tab dbms_sql.varchar2a;
begin
--out_tab := dbms_sql.varchar2a();
loc_ind_1 := 1;
loc_ind_2 := 1;
loc_string_length := length(inp_string);
while ( loc_ind_2 < loc_string_length ) loop
--out_tab.extend;
loc_curr_string := substr(inp_string,loc_ind_2,inp_length);
dbms_output.put(loc_curr_string);
out_tab(loc_ind_1) := loc_curr_string;
loc_ind_1 := loc_ind_1 + 1;
loc_ind_2 := loc_ind_2 + length(loc_curr_string);
end loop;
dbms_output.put_line('');
return out_tab;
end;
function execute_statement(
inp_statement in varchar2,
inp_binds in string_table,
inp_parameters in parametri
return number
is
loc_stat dbms_sql.varchar2a;
loc_dyn_cur number;
out_rows number;
begin
loc_stat := divide_string(inp_statement);
loc_dyn_cur := dbms_sql.open_cursor;
dbms_sql.parse(c => loc_dyn_cur,
statement => loc_stat,
lb => loc_stat.first,
ub => loc_stat.last,
lfflg => false,
language_flag => dbms_sql.native
for i in inp_binds.first .. inp_binds.last loop
DBMS_SQL.BIND_VARIABLE(loc_dyn_cur, inp_binds(i), inp_parameters(inp_binds(i)));
dbms_output.put_line(':'||inp_binds(i)||'='||inp_parameters(inp_binds(i)));
end loop;
dbms_output.put_line('');
--out_rows := DBMS_SQL.EXECUTE(loc_dyn_cur);
DBMS_SQL.CLOSE_CURSOR(loc_dyn_cur);
return out_rows;
end;Bye Alessandro
Message was edited by:
Alessandro Rossi
There is something missing in the functions but if there is something that may interest you you can ask. -
Monitor BizTalk Host Queue length and suspended msgs w/SCOM
First, I hope the BizTalk forum is the right place to ask this. Maybe I should try the SCOM forum as well.
I'm trying to create two monitors (Not rules, as we want the alert to be automatically healthy when under treshold again and we want to see the status state as well) in SCOM based on performance counters for BizTalk Msgbox Host Queue Length and suspended
msgs. My question is what I should use as target (class) in SCOM? And can I use "All instances" of the counter or must i create a monitor for each instance (This is a lot of work and not very dynamic)? We want to monitor all the instances/hosts with
different tresholds, so the first thing I did was to target the "BizTalk Host" class, so I can do overrides to different hosts.
The problem with this is it will generete a alert for all hosts if one instance is over treshold. I also tried to target the "Run-time role", and this actually works better, but not perfect as i cannot set a treshold for just one instance/host
then and it will close the alert if any other intance is under treshold.
Anyone have experiences with SCOM and monitoring Hosts queues and/or suspended msgs as monitors?
thank you in advance for all suggestions!I would suggest to look into spool table and its size . As per recommendation it count should not be greater than 3000 per server .
Its easy way to monitor the performance counter "Message Box:General Counters /Spool size".you can execute one the following SQL in the BizTalk message box database.
You can have a counter for spool table size and manually you can use below sql query to find out the count.
SELECT count(*) from SPOOL WITH (NOLOCK)
SELECT top 1 rows FROM sys.partitions WHERE object_id = object_id(‘spool’)
Note :The NOLOCK keyword is important in first query, you don’t want to put any locks in the spool table while measuring the row count. The second query is the one used by the performance counter “Spool Size” using the stored procedure
“MsgBoxPerfCounters_GetSpoolSize”
Reference :http://msdn.microsoft.com/en-us/library/aa561922.aspx
Thanks
Abhishek -
Hello everyone,
I am using the following MDX query on one of my SSRS report.
SELECT NON EMPTY { [Measures].[Days Outstanding], [Measures].[Amt] } ON COLUMNS,
NON EMPTY { ([Customer].[Customer].[Customer Key].ALLMEMBERS) }
HAVING [Measures].[ Days Outstanding] > 60
DIMENSION PROPERTIES MEMBER_CAPTION, MEMBER_UNIQUE_NAME ON ROWS
FROM ( SELECT ( STRTOSET(@Location, CONSTRAINED)) ON COLUMNS
FROM ( SELECT ( {[Date].[Fiscal Period].&[2014-06]}) ON COLUMNS
FROM [Model]))
Over here, the data is being filtered always for current month and for a location that is being selected by user from a report selection parameter.
I would like to get the count of total no. of customers and sum of the amount measure.
When I am using them in calculated members it gives incorrect values. It considers all records (ignores the sub-select statements) instead of only the records of current month and selected location.
I also tried with EXISTING keyword in calculated members but there is not difference in output. Finally, I manage the same at SSRS level.
Can anybody please advise what are the ways to get the required sum of [Measures].[Amt] and count of [Customer].[Customer].[Customer Key].ALLMEMBERS dimension?
Also, does it make any difference if I manage it as SSRS level and not at MDX query level?
Any help would be much appreciated.
Thanks, Ankit Shah
Inkey Solutions, India.
Microsoft Certified Business Management Solutions Professionals
http://www.inkeysolutions.com/MicrosoftDynamicsCRM.htmlCan anybody please advise what are the ways to get the required sum of [Measures].[Amt] and count of [Customer].[Customer].[Customer Key].ALLMEMBERS dimension?
Also, does it make any difference if I manage it as SSRS level and not at MDX query level?
Hi Ankit,
We can use SUM function and COUNT function to sum of [Measures].[Amt] and count of [Customer].[Customer].[Customer Key].ALLMEMBERS dimension. Here is a sample query for you reference.
WITH MEMBER [measures].[SumValue] AS
SUM([Customer].[Customer].ALLMEMBERS,[Measures].[Internet Sales Amount])
MEMBER [measures].[CountValue] AS
COUNT([Customer].[Customer].ALLMEMBERS)
MEMBER [Measures].[DimensionName] AS [Customer].NAME
SELECT {[Measures].[DimensionName],[measures].[SumValue],[measures].[CountValue]} ON 0
FROM [Adventure Works]
Besides, you ask that does it make any difference if I manage it as SSRS level and not at MDX query level. I don't thinks it will make much difference. The total time to generate a reporting server report (RDL) can be divided into 3 elements:Time to retrieve
the data (TimeDataRetrieval);Time to process the report (TimeProcessing);Time to render the report (TimeRendering). If you manage it on MDX query level, then the TimeDataRetrieval might a little longer. If you manage it on report level, then the TimeProcessing
or TimeRendering time might a little longer. You can test it on you report with following query:
SELECT Itempath, TimeStart,TimeDataRetrieval + TimeProcessing + TimeRendering as [total time],
TimeDataRetrieval, TimeProcessing, TimeRendering, ByteCount, [RowCount],Source
FROM ExecutionLog3
WHERE itempath like '%reportname'
Regards,
Charlie Liao
TechNet Community Support -
Sender File Adapter. Fixed Lengths and Field Separator
Hello guys,
I have a doubt in Sender File Adapter with Content Conversion.
I have a text file like:
a,b,c,,e
I have the configuration in the adapter:
Register.fieldNames: a,b,c,d,e
Register.fieldSeparator: ,
The question I have is can I format the length of the text when i create the XML?
I woul like to create the XML like:
<Row>
<Register>
<a>a </a>
<a>b </a>
<a>c </a>
<a> </a>
<a>e </a>
</Register>
</Row>
I would like that when I create the file in Field A I have length = 4, but I have only 1 in the entry, and I want to fill the rest of the length with spaces.
I tried with FieldFixedLengths but when I test it the fields are not being formatted and take the commas as part of the field.
I know that this can be done in Receiver File Adapter, you leave for example one field of 5 length and you format it to 12 length with spaces.
Is this possible for Sender File ADapter?
Many thanks.
Regards,
Xavi.hi,
See the example given in this bog, in this blog the string has been splited into different fields as per the field length, so you may use the same concept to get your output.
/people/anish.abraham2/blog/2005/06/08/content-conversion-patternrandom-content-in-input-file
I hope it helps you.
Regards,
Sarvesh -
When i use view as list in finder and open a folder with many files i cant right click with mouse without selecting or highlighting a file....i just want to right click to paste an item or create a new folder...what can i do?
Thx for that im gonna try it....but is there a way to do it without using toolbar or cmd-c...? i mean using only the mouse?why does it have to highlight the file even though i click a bit next to it....?using icon view i can right click next to the folder and i wont have a problem but with list view that i prefer using it will highlight the whole row.....and i dont find free space to right click cause i got many files
-
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. -
Total count and count based on column value
Primaryid Id Status
1 50 1
2 50 1
3 50 1
4 50 3
5 50 2
6 50 1
7 51 1
8 51 2Im looking for a query which returns total count of rows for id 50 and count of rows with status 1
something like
Id count_total count_total_status1
50 6 4
51 2 1Any suggestion ?SQL> select * from t4;
PID ID STATUS
1 50 1
2 50 1
3 50 1
4 50 3
5 50 2
6 50 1
7 51 1
8 51 2
已选择8行。
SQL> select distinct id,count(id),sum(decode(status,1,1,0)) from t4 group by id;
ID COUNT(ID) SUM(DECODE(STATUS,1,1,0))
51 2 1
50 6 4 -
Max, Min and Count with Group By
Hello,
i want the max, min and count of a table, which is grouped by a column
I need a combination of these two selects:
select
max(COUNTRY_S) MAXVALUE,
min(COUNTRY_S) MINVALUE
from
tab_Country
select
count(*)
from
(select COUNTRY_TXT from tab_Country group by COUNTRY_TXT) ;
The result should be one row with the max and min value of the table and with the count of the grouped by table, not the max and min of each group! - i hope you understand my question?
Is this possible in one SQL-select?
Thank you very much
Best regards
HeidiHi, Heidi,
HeidiWeber wrote:
Hello,
i want the max, min and count of a table, which is grouped by a column
I need a combination of these two selects:
select
max(COUNTRY_S) MAXVALUE,
min(COUNTRY_S) MINVALUE
from
tab_Country
select
count(*)
from
(select COUNTRY_TXT from tab_Country group by COUNTRY_TXT) ;
The result should be one row with the max and min value of the table and with the count of the grouped by table, not the max and min of each group! - i hope you understand my question?
Is this possible in one SQL-select?
Thank you very much
Best regards
Heidi
It's not clear what you want. Perhaps
SELECT MAX (country_s) AS max_country_s
, MIN (country_s) AS min_country_s
, COUNT (DISTINCT country_txt) AS count_country_txt
FROM tab_country
I hope this answers your question.
If not, post a little sample data (CREATE TABLE and INSERT statements, relevant columns only) for all the tables involved, and the results you want from that data.
Explain, using specific examples, how you get those results from that data.
Always say what version of Oracle you're using (e.g. 11.2.0.2.0).
See the forum FAQ: https://forums.oracle.com/message/9362002 -
Item(select list) with LOV and Report with link = changed value item
Hello,
On one page I have:
- Item 'P_name' (select list) with LOV to select name of a person;
- Items 'factory' and Report 'factory'(standard created with 'Form with Report' on the same page).
Situation:
All works fine. I selected first a LOV Item 'P_name' (say 'Jane'). But....
Only when I select a record (to change the values) from the report 'factory' then LOV Item 'P_name' become empty. Report used a link to the same page to fill the report items 'factory' and make also the LOV item empty.
Question:
I have made a process that write the name 'Jane' to table.
I see two possibilities:
- LOV Item value => fill the LOV item with 'Jane' from the table before region. Is this possible?
- Report => What is the buttonname of reportlink? I can use this name in the processes.
Thanks Walter!1) what i meant was for you to test this ridiculously huge LOV outside of htmldb, but it occurred to me last night that you could, in fact, be hitting a limit of ours. after some poking around, i have confirmed that. select list items in htmldb are currently limited to 10,000 rows. this was initially done for performance reasons, but they're now opening up the restriction. if you really need to work with that many rows where the user is allowed to pick from a set of values, consider using a popup item type instead. it'd help your app performance as well (in my test cases, it stank to have to wait for my 10k select list rows to come down to my browser).
2) sorry to not have been more clear about this, but when you set your item's "Source Type" back to "Database Column", you'd have to specify that column in the "Source or value expression" field. also, you can't put a sql query into that "Post Calculation Computation" field. as i said before, "you can take a look at the attribute-level help for that field to see implementation examples."
3) stick with "Always..." for now if you're using our auto-dml process(es)
regards,
raj
Maybe you are looking for
-
Safari Crashes when opening a new tap
Hi! Was wondering if anyone could help me with this before I go into the genius bar. Safari keeps crashing when I try to open a new tap (command + T) but not when I click on a link to open in a new tap. I have deleted all plug ins from the following:
-
Hi, I am having an application which consists of JFrames on which JInternal Frames are added through JDeskTopPanes. I am facing two problems : 1. When I iconify the JInternalFrames, I am unable to see the incons in the bottom of the JFrame. 2. How ca
-
Applying same rating to all photos in a stack?
Is there a way to quickly apply the same rating, flag or color to all photos in the same stack? I couldn't find it.
-
Dear All, How can I change automaticule posting level 01 into 10. I have a lof of documents with posting level 01 and when I execute task: balance forrward this posting level is changed in posting level 00. I cannot load data from SAP correctly to n
-
Saving JPG with exif 2.1
I have a Sony TV with USB media port. It will not display images which were saved in Photoshop Elements 9, because the Sony requires JPG EXIF 2.1 format. How can I save files in APE in that format?