Count If Else
Hi everyone, Along with some other fields I have a table in my report with the below two columns.
The ACCOUNT NUMBER in the table repeats, but is unique when the DECISION column is factored in.
I'm trying to find a way to count "Decision" once per Account number.
In a way I need to be able to do some kind of compare between all the decision before per a unique account number and count it base on value of the decision.
A unique account number can have up to three (3) instances (Decsions) in the table
So for example
If DECISION = "DENY" for any instance of that specific account number, ignore every other instance and add 1 to the DENY count bucket
Else if DECISION = "PAY" for all instances of a specific account number add 1 to the PAY count bucket
Else if DECISION <> "DENY" but Decision = "CHANGE" for any instances of a specific account number add 1 to the CHANGE count bucket
So in the end my count should look like this:
DENY = 2
PAY = 1
CHANGE = 2
I've tried using =Count([ACCOUNT NUMBER]) In([DECISION]) But that gave me higher numbers that it should. For example PAY ended up equaling 3 when it should have been 1. And i can't seem to get the sytax right for my if statments for all other attempts.
Any assistance will be greatly appreciated!!!
Hi Marlon,
Please follow below step to get desired count.
1.Create a formula variable "DecisionNo" as below. Make it as dimension.
=If([Decision]= "PAY") Then 1 ElseIf([Decision]= "CHANGE") Then 2 Else 3
2. Create second formula varibale as "Max Decision" as below.
=[Decision] Where([DecisionNo.] = Max([DecisionNo.] In([Account Number]; [Decision]))In([Account Number]))
3. Create third formula variable as "Detail Decision" as below. Make this as a detail of account number.
=[Max Decision]
4. Now Put [Detail Decision] and Count([Account Number]) in vertical table. Make a filter on [Detail Decision] as is not Null.
5. Now you will see count what you want.
Regards
Rakesh
Similar Messages
-
Bin fitting with a counter using both analytics and model clause.
11.2.0.3
This falls under 'just want to figure out how to do it'. Its not critical for work. I want to try to see if its possible to do this with both analytic function and with a model clause. Just to see if its possible. It has been stumping me.
I got the idea to look at this from this article about bin fitting. I have been playing with the model clause and I think you would do something with the 'increment' clause, but I dont see a way to reset it to 1 at a certain point.
http://www.oracle.com/technetwork/issue-archive/2012/12-mar/o22asktom-1518271.html
The case I want to look at is, bin fitting based on a counter and a partition by. In theory this should be simpler than the example in the link.
[code]
create table myrooms (
room_number number,
person_id number);
create unique index myrooms_ind on myrooms(room_number,person_id);
[/code]
Person_id is not unique. So row_number is more appropriate than rank or dense_rank.
Problem: Partition by room_number, assign up to 50 people to a specific group with in the same room. This seems like it could be handled with a row_number() and a window clause, but that is not supported.
I need to basically translate the old procedural counter into sql:
pseudo-code that does not compile that would have a reason to use this logic.
[code]
declare
cursor curGetRoom
select room_number,person_id
from my rooms
order by room_number;
counter number := 1;
vCurrentRoom myroom.room_number%type;
begin
for i in curGetRoom loop
if vCurrentRoom is null then
vCurrentRoom := i.room_number;
elsif vCurrentRoom = i.room_number then
if counter < 51 then counter :=counter+1;
else counter := 1;
else
vCurrentRoom := i.room_number;
counter :=1;
end if;
end;
[/code]
simple partition query., but I dont see a way to limit this to 50 and then start over. Window functions are not supported with row_number()
[code]
select room_number,person_id,row_number() over (partition by room_number order by person_id) rn
from myrooms
[/code]11.2.0.3
This falls under 'just want to figure out how to do it'. Its not critical for work. I want to try to see if its possible to do this with both analytic function and with a model clause. Just to see if its possible. It has been stumping me.
I got the idea to look at this from this article about bin fitting. I have been playing with the model clause and I think you would do something with the 'increment' clause, but I dont see a way to reset it to 1 at a certain point.
http://www.oracle.com/technetwork/issue-archive/2012/12-mar/o22asktom-1518271.html
The case I want to look at is, bin fitting based on a counter and a partition by. In theory this should be simpler than the example in the link.
[code]
create table myrooms (
room_number number,
person_id number);
create unique index myrooms_ind on myrooms(room_number,person_id);
[/code]
Person_id is not unique. So row_number is more appropriate than rank or dense_rank.
Problem: Partition by room_number, assign up to 50 people to a specific group with in the same room. This seems like it could be handled with a row_number() and a window clause, but that is not supported.
I need to basically translate the old procedural counter into sql:
pseudo-code that does not compile that would have a reason to use this logic.
[code]
declare
cursor curGetRoom
select room_number,person_id
from my rooms
order by room_number;
counter number := 1;
vCurrentRoom myroom.room_number%type;
begin
for i in curGetRoom loop
if vCurrentRoom is null then
vCurrentRoom := i.room_number;
elsif vCurrentRoom = i.room_number then
if counter < 51 then counter :=counter+1;
else counter := 1;
else
vCurrentRoom := i.room_number;
counter :=1;
end if;
end;
[/code]
simple partition query., but I dont see a way to limit this to 50 and then start over. Window functions are not supported with row_number()
[code]
select room_number,person_id,row_number() over (partition by room_number order by person_id) rn
from myrooms
[/code] -
Find word in text file and count specific words
now I'll try to explain what I need to do. I have file.txt file, It looks like:
John //first line - name
One
Three
Four
Peter //first line - name
Two
Three
Elisa //first line - name
One
Three
Albert //first line - name
One
Three
Four
Nicole //first line - name
Two
FourSo I have program's code:
public class Testing {
public static void main(String args[]) throws Exception {
Scanner input = new Scanner(System.in);
System.out.println("Select word from list:");
System.out.println();
try {
FileReader fr = new FileReader("src/lt/kvk/i3_2/test/List.txt"); // this is list of words, everything all right here
BufferedReader br = new BufferedReader(fr);
String s;
while((s = br.readLine()) != null) {
System.out.println(s);
fr.close();
String stilius = input.nextLine(); // eneter word which I want to count in File.txt
BufferedReader bf = new BufferedReader(new FileReader("src/lt/kvk/i3_2/test/File.txt")); // from this file I need to count word which I entered before
int counter = 0;
String line;
System.out.println("Looking for information");
while (( line = bf.readLine()) != null){
int indexfound = line.indexOf(stilius);
if (indexfound > -1) {
counter++;
if (counter > 0) {
System.out.println("Word are repeated "+ counter + "times");}
else {
System.out.println("Error...");
bf.close();
catch (IOException e) {
System.out.println("Error:" + e.toString());
}This program counting specific word (entered by keyboard) in file.txt.
I need to make this program: for ex.: if I enter word: One It must show:
Word One repeated 3 times by John, Elisa, AlbertAll what I need to elect by who this word repeated. But I don't know really how to make It, maybe LinkedList or I dont know, someone could help me?
Thank you very much.966676 wrote:
All what I need to elect by who this word repeated. But I don't know really how to make It, maybe LinkedListYou should choose the simplest type fullfilling your needs. In this case I'd go for <tt>HashSet</tt> or <tt>ArrayList</tt>.
or I dont know, someone could help me?You need to introduce a variable to store the actual name which must be resetted if an empty line is found and then gets assigned the verry next word in the file.
bye
TPD -
Analytic function to count rows based on Special criteria
Hi
I have the following query with analytic function but wrong results on the last column COUNT.
Please help me to achive the required result.Need to change the way how I select the last column.
1)I am getting the output order by b.sequence_no column . This is a must.
2)COUNT Column :
I don't want the total count based on thor column hence there is no point in grouping by that column.
The actual requirement to achieve COUNT is:
2a -If in the next row, if either the THOR and LOC combination changes to a new value, then COUNT=1
(In other words, if it is different from the following row)
2b-If the values of THOR and LOC repeats in the following row, then the count should be the total of all those same value rows until the rows become different.
(In this case 2b-WHERE THE ROWS ARE SAME- also I only want to show these same rows only once. This is shown in the "MY REQUIRED OUTPUT) .
My present query:
select r.name REGION ,
p.name PT,
do.name DELOFF,
ro.name ROUTE,
decode(th.thorfare_name,'OSIUNKNOWN',NULL,th.thorfare_name)
THOR,
l.name LOC ,
b.sequence_no SEQ,
CASE WHEN th.thorfare_name = LAG (th.thorfare_name)
OVER (order by b.sequence_no)
or th.thorfare_name = LEAD (th.thorfare_name)
OVER (order by b.sequence_no)
THEN COUNT(b.sequence_no) OVER (partition by r.name,th.thorfare_name,l.name order BY b.sequence_no
ELSE 1
END COUNT
from t_regions r,t_post_towns p,t_delivery_offices do, t_routes ro, t_counties c,t_head_offices ho,
t_buildings b,t_thoroughfares th,t_localities l
where th.thorfare_id = b.thorfare_id
and nvl(b.invalid,'N')='N'
and b.route_id=ro.route_id(+)
and b.locality_id =l.locality_id(+)
and ro.delivery_office_id=do.delivery_office_id(+)
and do.post_town_id = p.post_town_id(+)
and p.ho_id=ho.ho_id(+)
and ho.county_id = c.county_id(+)
and c.region_id = r.region_id(+)
and r.name='NAAS'
and do.DELIVERY_OFFICE_id= &&DELIVERY_OFFICE_id
and ro.route_id=3405
group by r.name,p.name,do.name,ro.name,th.thorfare_name,l.name,b.sequence_no
ORDER BY ro.name,b.sequence_no;My incorrect output[PART OF DATA]:
>
REGION PT DELOFF ROUTE THOR LOC SEQ COUNT
NAAS NAAS MAYNOOTH MAYNOOTHR010 DUBLINRD CEL 1 1
NAAS NAAS MAYNOOTH MAYNOOTHR010 NEWTOWNRD CEL 2 1
NAAS NAAS MAYNOOTH MAYNOOTHR010 PRIMHILL CEL 4 1
NAAS NAAS MAYNOOTH MAYNOOTHR010 NEWTOWNRD CEL 5 1
NAAS NAAS MAYNOOTH MAYNOOTHR010 THEGROVE CEL 2 1
NAAS NAAS MAYNOOTH MAYNOOTHR010 NEWTOWNRD CEL 7 3
NAAS NAAS MAYNOOTH MAYNOOTHR010 NEWTOWNRD CEL 8 4
NAAS NAAS MAYNOOTH MAYNOOTHR010 NEWTOWNRD CEL 9 5
NAAS NAAS MAYNOOTH MAYNOOTHR010 NEWTOWNRD CEL 10 6
NAAS NAAS MAYNOOTH MAYNOOTHR010 NEWTOWNRD CEL 11 7
NAAS NAAS MAYNOOTH MAYNOOTHR010 NEWTOWNRD CEL 12 8
NAAS NAAS MAYNOOTH MAYNOOTHR010 DUBLINRD CEL 15 2
NAAS NAAS MAYNOOTH MAYNOOTHR010 DUBLINRD CEL 19 3
NAAS NAAS MAYNOOTH MAYNOOTHR010 DUBLINRD CEL 24 4
NAAS NAAS MAYNOOTH MAYNOOTHR010 DUBLINRD CEL 29 5
NAAS NAAS MAYNOOTH MAYNOOTHR010 DUBLINRD CEL 34 6
NAAS NAAS MAYNOOTH MAYNOOTHR010 DUBLINRD CEL 39 7
NAAS NAAS MAYNOOTH MAYNOOTHR010 DUBLINRD CEL 42 2
NAAS NAAS MAYNOOTH MAYNOOTHR010 PRIMHILL CEL 43 2
NAAS NAAS MAYNOOTH MAYNOOTHR010 PRIMHILL CEL 44 3
My required output[PART OF DATA]-Please compare with the above.:
>
REGION PT DELOFF ROUTE THOR LOC COUNT
NAAS NAAS MAYNOOTH MAYNOOTHR010 DUBLINRD CEL 1
NAAS NAAS MAYNOOTH MAYNOOTHR010 NEWTOWNRD CEL 1
NAAS NAAS MAYNOOTH MAYNOOTHR010 PRIMHILL CEL 1
NAAS NAAS MAYNOOTH MAYNOOTHR010 NEWTOWNRD CEL 1
NAAS NAAS MAYNOOTH MAYNOOTHR010 THEGROVE CEL 1
NAAS NAAS MAYNOOTH MAYNOOTHR010 NEWTOWNRD CEL 6
NAAS NAAS MAYNOOTH MAYNOOTHR010 DUBLINRD CEL 7
NAAS NAAS MAYNOOTH MAYNOOTHR010 PRIMHILL CEL 2
NOTE :Count as 1 is correctly coming.
But where there is same rows and I want to take the total count on them, I am not getting.
Pls pls help.
Thanks
Edited by: Krithi on 04-Nov-2010 05:28Nicosa wrote:
Hi,
Can you give us some sample data (create table + inserts orders) to play with ?
Considering your output, I'm not even sure you need analytic count.Yes sure.
I am describing the query again here with 3 tables now to make this understand better.
Given below are the create table statements and insert statements for these 3 tables.
These tables are - BULDINGSV,THORV and LOCV
CREATE TABLE BUILDINGSV
BUILDING_ID NUMBER(10) NOT NULL,
INVALID VARCHAR2(1 BYTE),
ROUTE_ID NUMBER(10),
LOCALITY_ID NUMBER(10),
SEQUENCE_NO NUMBER(4),
THORFARE_ID NUMBER(10) NOT NULL
CREATE TABLE THORV
THORFARE_ID NUMBER(10) NOT NULL,
THORFARE_NAME VARCHAR2(40 BYTE) NOT NULL
CREATE TABLE LOCV
LOCALITY_ID NUMBER(10) NOT NULL,
NAME VARCHAR2(40 BYTE) NOT NULL);
Insert into BUILDINGSV
(BUILDING_ID, INVALID, ROUTE_ID, LOCALITY_ID, SEQUENCE_NO, THORFARE_ID)
Values
(59002372, 'N', 3405, 37382613, 5, 9002375);
Insert into BUILDINGSV
(BUILDING_ID, INVALID, ROUTE_ID, LOCALITY_ID, SEQUENCE_NO, THORFARE_ID)
Values
(59002363, 'N', 3405, 37382613, 57, 9002364);
Insert into BUILDINGSV
(BUILDING_ID, INVALID, ROUTE_ID, LOCALITY_ID, SEQUENCE_NO, THORFARE_ID)
Values
(59002362, 'N', 3405, 37382613, 56, 9002364);
Insert into BUILDINGSV
(BUILDING_ID, INVALID, ROUTE_ID, LOCALITY_ID, SEQUENCE_NO, THORFARE_ID)
Values
(59002360, 'N', 3405, 37382613, 52, 9002364);
Insert into BUILDINGSV
(BUILDING_ID, INVALID, ROUTE_ID, LOCALITY_ID, SEQUENCE_NO, THORFARE_ID)
Values
(59002358, 'N', 3405, 37382613, 1, 9002364);
Insert into BUILDINGSV
(BUILDING_ID, INVALID, ROUTE_ID, LOCALITY_ID, SEQUENCE_NO, THORFARE_ID)
Values
(59002240, 'N', 3405, 37382613, 6, 9002284);
Insert into BUILDINGSV
(BUILDING_ID, INVALID, ROUTE_ID, LOCALITY_ID, SEQUENCE_NO, THORFARE_ID)
Values
(59002229, 'N', 3405, 37382613, 66, 35291883);
Insert into BUILDINGSV
(BUILDING_ID, INVALID, ROUTE_ID, LOCALITY_ID, SEQUENCE_NO, THORFARE_ID)
Values
(59002228, 'N', 3405, 37382613, 65, 35291872);
Insert into BUILDINGSV
(BUILDING_ID, INVALID, ROUTE_ID, LOCALITY_ID, SEQUENCE_NO, THORFARE_ID)
Values
(59002226, 'N', 3405, 37382613, 62, 35291883);
Insert into BUILDINGSV
(BUILDING_ID, INVALID, ROUTE_ID, LOCALITY_ID, SEQUENCE_NO, THORFARE_ID)
Values
(59002222, 'N', 3405, 37382613, 43, 35291883);
Insert into BUILDINGSV
(BUILDING_ID, INVALID, ROUTE_ID, LOCALITY_ID, SEQUENCE_NO, THORFARE_ID)
Values
(59002217, 'N', 3405, 37382613, 125, 35291883);
Insert into BUILDINGSV
(BUILDING_ID, INVALID, ROUTE_ID, LOCALITY_ID, SEQUENCE_NO, THORFARE_ID)
Values
(59002221, 'N', 3405, 37382613, 58, 9002364);
Insert into BUILDINGSV
(BUILDING_ID, INVALID, ROUTE_ID, LOCALITY_ID, SEQUENCE_NO, THORFARE_ID)
Values
(59002214, 'N', 3405, 37382613, 128, 35291883);
Insert into BUILDINGSV
(BUILDING_ID, INVALID, ROUTE_ID, LOCALITY_ID, SEQUENCE_NO, THORFARE_ID)
Values
(33363182, 'N', 3405, 37382613, 114, 35291883);
Insert into BUILDINGSV
(BUILDING_ID, INVALID, ROUTE_ID, LOCALITY_ID, SEQUENCE_NO, THORFARE_ID)
Values
(33363185, 'N', 3405, 37382613, 115, 35291883);
Insert into BUILDINGSV
(BUILDING_ID, INVALID, ROUTE_ID, LOCALITY_ID, SEQUENCE_NO, THORFARE_ID)
Values
(59002371, 'N', 3405, 37382613, 2, 9002375);
Insert into BUILDINGSV
(BUILDING_ID, INVALID, ROUTE_ID, LOCALITY_ID, SEQUENCE_NO, THORFARE_ID)
Values
(27003329, 'N', 3405, 37382613, 415, 9002375);
Insert into BUILDINGSV
(BUILDING_ID, INVALID, ROUTE_ID, LOCALITY_ID, SEQUENCE_NO, THORFARE_ID)
Values
(59002359, 'N', 3405, 37382613, 15, 9002364);
Insert into BUILDINGSV
(BUILDING_ID, INVALID, ROUTE_ID, LOCALITY_ID, SEQUENCE_NO, THORFARE_ID)
Values
(59002224, 'N', 3405, 37382613, 61, 35291883);
Insert into BUILDINGSV
(BUILDING_ID, INVALID, ROUTE_ID, LOCALITY_ID, SEQUENCE_NO, THORFARE_ID)
Values
(27003318, 'N', 3405, 37382613, 411, 9002375);
Insert into BUILDINGSV
(BUILDING_ID, INVALID, ROUTE_ID, LOCALITY_ID, SEQUENCE_NO, THORFARE_ID)
Values
(27003326, 'N', 3405, 37382613, 412, 9002375);
Insert into BUILDINGSV
(BUILDING_ID, INVALID, ROUTE_ID, LOCALITY_ID, SEQUENCE_NO, THORFARE_ID)
Values
(27003327, 'N', 3405, 37382613, 413, 9002375);
Insert into BUILDINGSV
(BUILDING_ID, INVALID, ROUTE_ID, LOCALITY_ID, SEQUENCE_NO, THORFARE_ID)
Values
(27003328, 'N', 3405, 37382613, 414, 9002375);
Insert into BUILDINGSV
(BUILDING_ID, INVALID, ROUTE_ID, LOCALITY_ID, SEQUENCE_NO, THORFARE_ID)
Values
(27003330, 'N', 3405, 37382613, 416, 9002375);
Insert into BUILDINGSV
(BUILDING_ID, INVALID, ROUTE_ID, LOCALITY_ID, SEQUENCE_NO, THORFARE_ID)
Values
(27003331, 'N', 3405, 37382613, 417, 9002375);
Insert into BUILDINGSV
(BUILDING_ID, INVALID, ROUTE_ID, LOCALITY_ID, SEQUENCE_NO, THORFARE_ID)
Values
(27003332, 'N', 3405, 37382613, 410, 9002375);
Insert into BUILDINGSV
(BUILDING_ID, INVALID, ROUTE_ID, LOCALITY_ID, SEQUENCE_NO, THORFARE_ID)
Values
(27004795, 'N', 3405, 37382613, 514, 9002375);
Insert into BUILDINGSV
(BUILDING_ID, INVALID, ROUTE_ID, LOCALITY_ID, SEQUENCE_NO, THORFARE_ID)
Values
(27004807, 'N', 3405, 37382613, 515, 9002375);
Insert into BUILDINGSV
(BUILDING_ID, INVALID, ROUTE_ID, LOCALITY_ID, SEQUENCE_NO, THORFARE_ID)
Values
(59002227, 'N', 3405, 37382613, 64, 35291872);
Insert into BUILDINGSV
(BUILDING_ID, INVALID, ROUTE_ID, LOCALITY_ID, SEQUENCE_NO, THORFARE_ID)
Values
(33230805, 'N', 3405, 37382613, 44, 35291883);
Insert into BUILDINGSV
(BUILDING_ID, INVALID, ROUTE_ID, LOCALITY_ID, SEQUENCE_NO, THORFARE_ID)
Values
(33231027, 'N', 3405, 37382613, 7, 9002375);
Insert into BUILDINGSV
(BUILDING_ID, INVALID, ROUTE_ID, LOCALITY_ID, SEQUENCE_NO, THORFARE_ID)
Values
(33231058, 'N', 3405, 37382613, 9, 9002375);
Insert into BUILDINGSV
(BUILDING_ID, INVALID, ROUTE_ID, LOCALITY_ID, SEQUENCE_NO, THORFARE_ID)
Values
(33231078, 'N', 3405, 37382613, 10, 9002375);
Insert into BUILDINGSV
(BUILDING_ID, INVALID, ROUTE_ID, LOCALITY_ID, SEQUENCE_NO, THORFARE_ID)
Values
(33231087, 'N', 3405, 37382613, 11, 9002375);
Insert into BUILDINGSV
(BUILDING_ID, INVALID, ROUTE_ID, LOCALITY_ID, SEQUENCE_NO, THORFARE_ID)
Values
(33231093, 'N', 3405, 37382613, 12, 9002375);
Insert into BUILDINGSV
(BUILDING_ID, INVALID, ROUTE_ID, LOCALITY_ID, SEQUENCE_NO, THORFARE_ID)
Values
(33229890, 'N', 3405, 37382613, 55, 9002364);
Insert into BUILDINGSV
(BUILDING_ID, INVALID, ROUTE_ID, LOCALITY_ID, SEQUENCE_NO, THORFARE_ID)
Values
(80561996, 'N', 3405, 34224751, 544, 35417360);
Insert into BUILDINGSV
(BUILDING_ID, INVALID, ROUTE_ID, LOCALITY_ID, SEQUENCE_NO, THORFARE_ID)
Values
(80561997, 'N', 3405, 34224751, 543, 35417360);
Insert into BUILDINGSV
(BUILDING_ID, INVALID, ROUTE_ID, LOCALITY_ID, SEQUENCE_NO, THORFARE_ID)
Values
(80561998, 'N', 3405, 34224751, 555, 35417360);
Insert into BUILDINGSV
(BUILDING_ID, INVALID, ROUTE_ID, LOCALITY_ID, SEQUENCE_NO, THORFARE_ID)
Values
(80562000, 'N', 3405, 34224751, 541, 35417360);
Insert into BUILDINGSV
(BUILDING_ID, INVALID, ROUTE_ID, LOCALITY_ID, SEQUENCE_NO, THORFARE_ID)
Values
(80562001, 'N', 3405, 34224751, 538, 35417360);
Insert into BUILDINGSV
(BUILDING_ID, INVALID, ROUTE_ID, LOCALITY_ID, SEQUENCE_NO, THORFARE_ID)
Values
(80562028, 'N', 3405, 35417256, 525, 0);
Insert into BUILDINGSV
(BUILDING_ID, INVALID, ROUTE_ID, LOCALITY_ID, SEQUENCE_NO, THORFARE_ID)
Values
(80562031, 'N', 3405, 35417256, 518, 35417271);
Insert into BUILDINGSV
(BUILDING_ID, INVALID, ROUTE_ID, LOCALITY_ID, SEQUENCE_NO, THORFARE_ID)
Values
(80562032, 'N', 3405, 35417256, 519, 35417271);
Insert into BUILDINGSV
(BUILDING_ID, INVALID, ROUTE_ID, LOCALITY_ID, SEQUENCE_NO, THORFARE_ID)
Values
(80562033, 'N', 3405, 35417256, 523, 35417271);
Insert into BUILDINGSV
(BUILDING_ID, INVALID, ROUTE_ID, LOCALITY_ID, SEQUENCE_NO, THORFARE_ID)
Values
(80561939, 'N', 3405, 34224751, 551, 35417360);
Insert into BUILDINGSV
(BUILDING_ID, INVALID, ROUTE_ID, LOCALITY_ID, SEQUENCE_NO, THORFARE_ID)
Values
(80561940, 'N', 3405, 34224751, 552, 35417360);
Insert into BUILDINGSV
(BUILDING_ID, INVALID, ROUTE_ID, LOCALITY_ID, SEQUENCE_NO, THORFARE_ID)
Values
(80561941, 'N', 3405, 34224751, 553, 35417360);
Insert into BUILDINGSV
(BUILDING_ID, INVALID, ROUTE_ID, LOCALITY_ID, SEQUENCE_NO, THORFARE_ID)
Values
(80561942, 'N', 3405, 35417256, 536, 0);
Insert into BUILDINGSV
(BUILDING_ID, INVALID, ROUTE_ID, LOCALITY_ID, SEQUENCE_NO, THORFARE_ID)
Values
(80561943, 'N', 3405, 35417256, 537, 0);
Insert into BUILDINGSV
(BUILDING_ID, INVALID, ROUTE_ID, LOCALITY_ID, SEQUENCE_NO, THORFARE_ID)
Values
(80561970, 'N', 3405, 35417256, 522, 35417271);
Insert into BUILDINGSV
(BUILDING_ID, INVALID, ROUTE_ID, LOCALITY_ID, SEQUENCE_NO, THORFARE_ID)
Values
(80561972, 'N', 3405, 35417256, 527, 35417271);
Insert into BUILDINGSV
(BUILDING_ID, INVALID, ROUTE_ID, LOCALITY_ID, SEQUENCE_NO, THORFARE_ID)
Values
(80561974, 'N', 3405, 35417256, 530, 35417271);
Insert into BUILDINGSV
(BUILDING_ID, INVALID, ROUTE_ID, LOCALITY_ID, SEQUENCE_NO, THORFARE_ID)
Values
(80561975, 'N', 3405, 35417256, 531, 35417271);
Insert into BUILDINGSV
(BUILDING_ID, INVALID, ROUTE_ID, LOCALITY_ID, SEQUENCE_NO, THORFARE_ID)
Values
(80561980, 'N', 3405, 34224751, 575, 35417360);
Insert into BUILDINGSV
(BUILDING_ID, INVALID, ROUTE_ID, LOCALITY_ID, SEQUENCE_NO, THORFARE_ID)
Values
(80561981, 'N', 3405, 34224751, 574, 35417360);
Insert into BUILDINGSV
(BUILDING_ID, INVALID, ROUTE_ID, LOCALITY_ID, SEQUENCE_NO, THORFARE_ID)
Values
(80561983, 'N', 3405, 34224751, 571, 35417360);
Insert into BUILDINGSV
(BUILDING_ID, INVALID, ROUTE_ID, LOCALITY_ID, SEQUENCE_NO, THORFARE_ID)
Values
(80561984, 'N', 3405, 34224751, 570, 35417360);
Insert into BUILDINGSV
(BUILDING_ID, INVALID, ROUTE_ID, LOCALITY_ID, SEQUENCE_NO, THORFARE_ID)
Values
(80561985, 'N', 3405, 34224751, 568, 35417360);
Insert into BUILDINGSV
(BUILDING_ID, INVALID, ROUTE_ID, LOCALITY_ID, SEQUENCE_NO, THORFARE_ID)
Values
(80561986, 'N', 3405, 34224751, 567, 35417360);
Insert into BUILDINGSV
(BUILDING_ID, INVALID, ROUTE_ID, LOCALITY_ID, SEQUENCE_NO, THORFARE_ID)
Values
(80561987, 'N', 3405, 34224751, 566, 35417360);
Insert into BUILDINGSV
(BUILDING_ID, INVALID, ROUTE_ID, LOCALITY_ID, SEQUENCE_NO, THORFARE_ID)
Values
(80561989, 'N', 3405, 34224751, 563, 35417360);
Insert into BUILDINGSV
(BUILDING_ID, INVALID, ROUTE_ID, LOCALITY_ID, SEQUENCE_NO, THORFARE_ID)
Values
(80561990, 'N', 3405, 34224751, 562, 35417360);
Insert into BUILDINGSV
(BUILDING_ID, INVALID, ROUTE_ID, LOCALITY_ID, SEQUENCE_NO, THORFARE_ID)
Values
(80561991, 'N', 3405, 34224751, 560, 35417360);
Insert into BUILDINGSV
(BUILDING_ID, INVALID, ROUTE_ID, LOCALITY_ID, SEQUENCE_NO, THORFARE_ID)
Values
(80561992, 'N', 3405, 34224751, 559, 35417360);
Insert into BUILDINGSV
(BUILDING_ID, INVALID, ROUTE_ID, LOCALITY_ID, SEQUENCE_NO, THORFARE_ID)
Values
(80561993, 'N', 3405, 34224751, 558, 35417360);
Insert into BUILDINGSV
(BUILDING_ID, INVALID, ROUTE_ID, LOCALITY_ID, SEQUENCE_NO, THORFARE_ID)
Values
(80561994, 'N', 3405, 34224751, 548, 35417360);
Insert into BUILDINGSV
(BUILDING_ID, INVALID, ROUTE_ID, LOCALITY_ID, SEQUENCE_NO, THORFARE_ID)
Values
(80561995, 'N', 3405, 34224751, 546, 35417360);
Insert into BUILDINGSV
(BUILDING_ID, INVALID, ROUTE_ID, LOCALITY_ID, SEQUENCE_NO, THORFARE_ID)
Values
(80562160, 'N', 3405, 37382613, 139, 35291878);
Insert into BUILDINGSV
(BUILDING_ID, INVALID, ROUTE_ID, LOCALITY_ID, SEQUENCE_NO, THORFARE_ID)
Values
(80562161, 'N', 3405, 37382613, 140, 35291878);
Insert into BUILDINGSV
(BUILDING_ID, INVALID, ROUTE_ID, LOCALITY_ID, SEQUENCE_NO, THORFARE_ID)
Values
(80562162, 'N', 3405, 37382613, 141, 35291878);
Insert into BUILDINGSV
(BUILDING_ID, INVALID, ROUTE_ID, LOCALITY_ID, SEQUENCE_NO, THORFARE_ID)
Values
(80562163, 'N', 3405, 37382613, 142, 35291878);
Insert into BUILDINGSV
(BUILDING_ID, INVALID, ROUTE_ID, LOCALITY_ID, SEQUENCE_NO, THORFARE_ID)
Values
(80562164, 'N', 3405, 37382613, 143, 35291878);
Insert into BUILDINGSV
(BUILDING_ID, INVALID, ROUTE_ID, LOCALITY_ID, SEQUENCE_NO, THORFARE_ID)
Values
(80562165, 'N', 3405, 37382613, 145, 35291878);
Insert into BUILDINGSV
(BUILDING_ID, INVALID, ROUTE_ID, LOCALITY_ID, SEQUENCE_NO, THORFARE_ID)
Values
(80562166, 'N', 3405, 37382613, 100, 35291883);
Insert into BUILDINGSV
(BUILDING_ID, INVALID, ROUTE_ID, LOCALITY_ID, SEQUENCE_NO, THORFARE_ID)
Values
(80562167, 'N', 3405, 37382613, 102, 35291883);
Insert into BUILDINGSV
(BUILDING_ID, INVALID, ROUTE_ID, LOCALITY_ID, SEQUENCE_NO, THORFARE_ID)
Values
(80562171, 'N', 3405, 37382613, 107, 35291883);
Insert into BUILDINGSV
(BUILDING_ID, INVALID, ROUTE_ID, LOCALITY_ID, SEQUENCE_NO, THORFARE_ID)
Values
(80562172, 'N', 3405, 37382613, 108, 35291883);
Insert into BUILDINGSV
(BUILDING_ID, INVALID, ROUTE_ID, LOCALITY_ID, SEQUENCE_NO, THORFARE_ID)
Values
(80562174, 'N', 3405, 37382613, 110, 35291883);
Insert into BUILDINGSV
(BUILDING_ID, INVALID, ROUTE_ID, LOCALITY_ID, SEQUENCE_NO, THORFARE_ID)
Values
(80562175, 'N', 3405, 37382613, 111, 35291883);
Insert into BUILDINGSV
(BUILDING_ID, INVALID, ROUTE_ID, LOCALITY_ID, SEQUENCE_NO, THORFARE_ID)
Values
(80562176, 'N', 3405, 37382613, 112, 35291883);
Insert into BUILDINGSV
(BUILDING_ID, INVALID, ROUTE_ID, LOCALITY_ID, SEQUENCE_NO, THORFARE_ID)
Values
(80562177, 'N', 3405, 37382613, 113, 35291883);
Insert into BUILDINGSV
(BUILDING_ID, INVALID, ROUTE_ID, LOCALITY_ID, SEQUENCE_NO, THORFARE_ID)
Values
(80562182, 'N', 3405, 37382613, 123, 35291883);
Insert into BUILDINGSV
(BUILDING_ID, INVALID, ROUTE_ID, LOCALITY_ID, SEQUENCE_NO, THORFARE_ID)
Values
(80562183, 'N', 3405, 37382613, 121, 35291883);
Insert into BUILDINGSV
(BUILDING_ID, INVALID, ROUTE_ID, LOCALITY_ID, SEQUENCE_NO, THORFARE_ID)
Values
(80562184, 'N', 3405, 37382613, 120, 35291883);
Insert into BUILDINGSV
(BUILDING_ID, INVALID, ROUTE_ID, LOCALITY_ID, SEQUENCE_NO, THORFARE_ID)
Values
(80562185, 'N', 3405, 37382613, 118, 35291883);
Insert into BUILDINGSV
(BUILDING_ID, INVALID, ROUTE_ID, LOCALITY_ID, SEQUENCE_NO, THORFARE_ID)
Values
(80562186, 'N', 3405, 37382613, 117, 35291883);
Insert into BUILDINGSV
(BUILDING_ID, INVALID, ROUTE_ID, LOCALITY_ID, SEQUENCE_NO, THORFARE_ID)
Values
(80562187, 'N', 3405, 37382613, 116, 35291883);
Insert into BUILDINGSV
(BUILDING_ID, INVALID, ROUTE_ID, LOCALITY_ID, SEQUENCE_NO, THORFARE_ID)
Values
(80562189, 'N', 3405, 37382613, 95, 35291883);
Insert into BUILDINGSV
(BUILDING_ID, INVALID, ROUTE_ID, LOCALITY_ID, SEQUENCE_NO, THORFARE_ID)
Values
(80562190, 'N', 3405, 37382613, 94, 35291883);
Insert into BUILDINGSV
(BUILDING_ID, INVALID, ROUTE_ID, LOCALITY_ID, SEQUENCE_NO, THORFARE_ID)
Values
(80562213, 'N', 3405, 37382613, 89, 35291872);
Insert into BUILDINGSV
(BUILDING_ID, INVALID, ROUTE_ID, LOCALITY_ID, SEQUENCE_NO, THORFARE_ID)
Values
(80562240, 'N', 3405, 35417256, 516, 35417271);
Insert into BUILDINGSV
(BUILDING_ID, INVALID, ROUTE_ID, LOCALITY_ID, SEQUENCE_NO, THORFARE_ID)
Values
(35329559, 'N', 3405, 35329152, 443, 35329551);
Insert into BUILDINGSV
(BUILDING_ID, INVALID, ROUTE_ID, LOCALITY_ID, SEQUENCE_NO, THORFARE_ID)
Values
(35329560, 'N', 3405, 35329152, 444, 35329551);
Insert into BUILDINGSV
(BUILDING_ID, INVALID, ROUTE_ID, LOCALITY_ID, SEQUENCE_NO, THORFARE_ID)
Values
(35329562, 'N', 3405, 35329152, 446, 35329551);
Insert into BUILDINGSV
(BUILDING_ID, INVALID, ROUTE_ID, LOCALITY_ID, SEQUENCE_NO, THORFARE_ID)
Values
(35329109, 'N', 3405, 35329152, 433, 35329181);
Insert into BUILDINGSV
(BUILDING_ID, INVALID, ROUTE_ID, LOCALITY_ID, SEQUENCE_NO, THORFARE_ID)
Values
(35329169, 'N', 3405, 35329152, 434, 35329181);
Insert into BUILDINGSV
(BUILDING_ID, INVALID, ROUTE_ID, LOCALITY_ID, SEQUENCE_NO, THORFARE_ID)
Values
(35329557, 'N', 3405, 35329152, 441, 35329551);
Insert into BUILDINGSV
(BUILDING_ID, INVALID, ROUTE_ID, LOCALITY_ID, SEQUENCE_NO, THORFARE_ID)
Values
(35329558, 'N', 3405, 35329152, 442, 35329551);
Insert into BUILDINGSV
(BUILDING_ID, INVALID, ROUTE_ID, LOCALITY_ID, SEQUENCE_NO, THORFARE_ID)
Values
(35329191, 'N', 3405, 35329152, 436, 35329181);
COMMIT;
Insert into THORV
(THORFARE_ID, THORFARE_NAME)
Values
(0, 'OSIUNKNOWN');
Insert into THORV
(THORFARE_ID, THORFARE_NAME)
Values
(9002284, 'THE GROVE');
Insert into THORV
(THORFARE_ID, THORFARE_NAME)
Values
(9002364, 'DUBLIN ROAD');
Insert into THORV
(THORFARE_ID, THORFARE_NAME)
Values
(9002375, 'NEWTOWN ROAD');
Insert into THORV
(THORFARE_ID, THORFARE_NAME)
Values
(35291872, 'HAZELHATCH ROAD');
Insert into THORV
(THORFARE_ID, THORFARE_NAME)
Values
(35291878, 'SIMMONSTOWN PARK');
Insert into THORV
(THORFARE_ID, THORFARE_NAME)
Values
(35291883, 'PRIMROSE HILL');
Insert into THORV
(THORFARE_ID, THORFARE_NAME)
Values
(35329181, 'THE COPSE');
Insert into THORV
(THORFARE_ID, THORFARE_NAME)
Values
(35329213, 'THE COURT');
Insert into THORV
(THORFARE_ID, THORFARE_NAME)
Values
(35329529, 'THE CRESCENT');
Insert into THORV
(THORFARE_ID, THORFARE_NAME)
Values
(35329551, 'THE LAWNS');
Insert into THORV
(THORFARE_ID, THORFARE_NAME)
Values
(35329580, 'THE DRIVE');
Insert into THORV
(THORFARE_ID, THORFARE_NAME)
Values
(35417271, 'TEMPLEMILLS COTTAGES');
Insert into THORV
(THORFARE_ID, THORFARE_NAME)
Values
(35417360, 'CHELMSFORD');
Insert into THORV
(THORFARE_ID, THORFARE_NAME)
Values
(36500023, 'THE CLOSE');
Insert into THORV
(THORFARE_ID, THORFARE_NAME)
Values
(36500101, 'THE GREEN');
Insert into THORV
(THORFARE_ID, THORFARE_NAME)
Values
(37375569, 'THE DOWNS');
Insert into THORV
(THORFARE_ID, THORFARE_NAME)
Values
(37375595, 'THE PARK');
Insert into THORV
(THORFARE_ID, THORFARE_NAME)
Values
(37375754, 'THE AVENUE');
Insert into THORV
(THORFARE_ID, THORFARE_NAME)
Values
(37375781, 'THE VIEW');
Insert into THORV
(THORFARE_ID, THORFARE_NAME)
Values
(37376046, 'THE CRESCENT');
Insert into THORV
(THORFARE_ID, THORFARE_NAME)
Values
(37376048, 'THE GLADE');
COMMIT;
Insert into LOCV
(LOCALITY_ID, NAME)
Values
(34224751, 'SIMMONSTOWN');
Insert into LOCV
(LOCALITY_ID, NAME)
Values
(35417256, 'TEMPLEMILLS');
Insert into LOCV
(LOCALITY_ID, NAME)
Values
(35329152, 'TEMPLE MANOR');
Insert into LOCV
(LOCALITY_ID, NAME)
Values
(37382613, 'CELBRIDGE');
Insert into LOCV
(LOCALITY_ID, NAME)
Values
(37375570, 'SAINT WOLSTAN''S ABBEY');
COMMIT;
------------------------------------------------------------------------------Now the query with wrong result:
select decode(th.thorfare_name,'OSIUNKNOWN',NULL,th.thorfare_name)
THOR,
l.name LOC,
b.sequence_no SEQ,
CASE WHEN th.thorfare_name = LAG (th.thorfare_name)
OVER (order by b.sequence_no)
or th.thorfare_name = LEAD (th.thorfare_name)
OVER (order by b.sequence_no)
THEN COUNT(b.sequence_no) OVER (partition by th.thorfare_name,l.name order BY b.sequence_no
ELSE 1
END COUNT from BUILDINGSV b,THORV th,LOCV l
where th.thorfare_id = b.thorfare_id
and nvl(b.invalid,'N')='N'
and b.route_id=3405
and b.locality_id =l.locality_id(+)
order by b.sequence_no;The query result -WRONG (only first few lines)
THOR LOC SEQ COUNT
DUBLIN ROAD CELBRIDGE 1 1
NEWTOWN ROAD CELBRIDGE 2 1
NEWTOWN ROAD CELBRIDGE 5 2
THE GROVE CELBRIDGE 6 1
NEWTOWN ROAD CELBRIDGE 7 3
NEWTOWN ROAD CELBRIDGE 9 4
NEWTOWN ROAD CELBRIDGE 10 5
NEWTOWN ROAD CELBRIDGE 11 6
NEWTOWN ROAD CELBRIDGE 12 7
DUBLIN ROAD CELBRIDGE 15 1
PRIMROSE HILL CELBRIDGE 43 1
PRIMROSE HILL CELBRIDGE 44 2
DUBLIN ROAD CELBRIDGE 52 3
DUBLIN ROAD CELBRIDGE 55 4
DUBLIN ROAD CELBRIDGE 56 5
DUBLIN ROAD CELBRIDGE 57 6
DUBLIN ROAD CELBRIDGE 58 7
PRIMROSE HILL CELBRIDGE 61 3
PRIMROSE HILL CELBRIDGE 62 4
HAZELHATCH ROAD CELBRIDGE 64 1
HAZELHATCH ROAD CELBRIDGE 65 2The query result -EXPECTED (only first few lines)
THOR LOC COUNT
DUBLIN ROAD CELBRIDGE 1
NEWTOWN ROAD CELBRIDGE 2
THE GROVE CELBRIDGE 1
NEWTOWN ROAD CELBRIDGE 5
DUBLIN ROAD CELBRIDGE 1
PRIMROSE HILL CELBRIDGE 2
DUBLIN ROAD CELBRIDGE 5
PRIMROSE HILL CELBRIDGE 2
HAZELHATCH ROAD CELBRIDGE 2Please note, in the expected result, I only need 1 row but need to show the total count of rows until the names change.
So the issues are
1) the count column values are wrong in my query.
2)I dont want to repeat the same rows(Please see EXPECTED output and compare it against the original)
3)Want the output in exactly same way as in EXPECTED OUTPUT as I dont want to group by thor name(Eg. I dont want the count for all DUBLIN ROAD but I want to examine rows for the next one, if THOR/LOC combination is different in next row then COUNT=1 else COUNT=Count of no. of rows for that thor/loc combination until the combination change -So there are same value multiple rows which i need to show it in 1 row with the total count)
I am explaining below this in more detail!!
I only need 1 row per same THOR/LOC names coming multiple times but I need the count shown against that 1 row(i.e COUNT= how many rows with same thor/loc combination until THOR/LOC combo changes value).
Then repeat the process until all rows are finished..
If there is no multiple row with same THOR/LOC coming in the following row-i.e the following row is a different THOR/LOC combination, then the count for that row is 1.
Hope this is clear.
Is this doable?
Thanks in advance.
Edited by: Krithi on 04-Nov-2010 07:45
Edited by: Krithi on 04-Nov-2010 07:45
Edited by: Krithi on 04-Nov-2010 08:31 -
HOW TO USE COUNTER FUNCTION IN BEX
RESPECTED ALL
I WISH TO CREATE A FORMULA KEY FIGURE AT REPORTING LEVEL WHICH SHOULD GIVE ME OUTPUT AS
1
2
3
4
5
6
7
THE LOGIC IS " IF YIELD IS GREATER THAN ZERO COUNT 1 ELSE COUNT ZERO AND IN THE NEXT ROW IT SHOULD GIVE ME NUMBER 2 IF IN LINE FIRST IT GETS 1"
IN A NUT SHELL I WANT TO CALCULATE TOTAL NO OF COILS WHICH DEPENDS UPON TOTAL NO OF YEILD
FIELD BY USER.
THANKS
ABHAYHi Abhay,
We can get your scenario via calculated key figure..
Below is the calculated key figure:
(Nodim(field)<=0)0+(Nodim(field)>=1)*1... *
Field represents your perticular key field.in the above cal key fig...if the field is less than or eqaul to 0 counter will show as 0,
Second condition is if the cal key fig is equal to 1 it will show 1 as the counter.
In the same way you can implement your scenario...
Hope this helps you..
Best Regards,
Maruthi -
Receiver determination - Xpath expression problem with count
I am working with a scenario where I pick up records from a JDBC connection and if the number of records I pick up is less than a certain number I want to call a webservice. If it is greater than the number I want to write out a file to be processed by a different process on the receiving end. I have created the receiver determination condition with the following conditions:
(/p1:MT_HOG_Data/row[count(row) > 3] EX)
(/p1:MT_HOG_Data/row[count(row) <= 3] EX)
The integration is always processing the second condition no matter how many records come in. I have tried with and without the multiline option. Can anyone help with this?
I have searched through the forum and checked the following links without any resolution:
http://wiki.sdn.sap.com/wiki/display/XI/XpathConditioninReceiverDetermination
http://help.sap.com/saphelp_nwpi71/helpdata/EN/ab/13bf7191e73a4fb3560e767a2525fd/frameset.htm
/people/shabarish.vijayakumar/blog/2006/06/07/customise-your-xpath-expressions-in-receiver-determination
I can't find any examples where a count of records is checked in the expression editor. Thanks in advance for any help.You can not use the EX operator in that case, because that is used only for node existence checks, not for value checks.
Do you have a row number in your structure ? Then you could write the xpath expression with that counter tag and value
Example: you want to send to receiver A if count > 3, else to B:
you set /rowNumber EQUAL 4 for sender A
and /rowNumber NOT EQUAL 4 for sender B
The condition is applied to the whole document. If one of the node/values are true for that condition, then the whole condition is set to true.
Problem with that is that the second condition also will be true because nodes for that condition will be found
better would be to have a rowcount tag in the structure. If that is not possible, you can use the "Enhanced Receiver determination" where you can define a mapping which determines the receivers. There you can do anything complicated you want.
CSY -
How can I count in Joins?
Hello,
I have the following table definitions:
--- Tables
CREATE TABLE group_test
(ID number NOT NULL,
group_name varchar2(20));
ALTER TABLE group_test ADD (CONSTRAINT group_test_p primary key (ID));
CREATE TABLE member_of_groups
(group_test_id number not null,
member varchar2(20));
ALTER TABLE member_of_groups ADD (CONSTRAINT gt_id_fk FOREIGN KEY (group_test_id) REFERENCES group_test(ID));
--- Fill in some data
insert into group_test (id,group_name) values(1,'group_1');
insert into group_test (id,group_name) values(2,'group_2');
insert into group_test (id,group_name) values(3,'group_3');
insert into group_test (id,group_name) values(4,'group_4');
insert into group_test (id,group_name) values(5,'group_5');
commit;
insert into member_of_groups (group_test_id,member) values (1,'Miller');
insert into member_of_groups (group_test_id,member) values (1,'Smith');
insert into member_of_groups (group_test_id,member) values (2,'Walker');
insert into member_of_groups (group_test_id,member) values (3,'Almeida');
insert into member_of_groups (group_test_id,member) values (3,'Walton');
insert into member_of_groups (group_test_id,member) values (3,'McScrooge');
insert into member_of_groups (group_test_id,member) values (4,'Hoover');
insert into member_of_groups (group_test_id,member) values (4,'Brando');
insert into member_of_groups (group_test_id,member) values (5,'Walther');
commit;
-------------------- Queries
select all group_test.group_name,member_of_groups.member from group_test, member_of_groups where group_test.id = member_of_groups.group_test_id;
---------- RESULT
GROUP_NAME MEMBER
group_1 Miller
group_1 Smith
group_2 Walker
group_3 Almeida
group_3 Walton
group_3 McScrooge
group_4 Hoover
group_4 Brando
group_5 Walther
select count(1) as counter from group_test, member_of_groups where group_test.id = member_of_groups.group_test_id group by group_test.group_name;
---------- RESULT
COUNTER
2
1
3
2
1
----- PL/SQL-Code
set serveroutput on
DECLARE
counter number := 0;
group_store group_test.group_name%TYPE := '';
mem_store member_of_groups.member%TYPE := '';
BEGIN
for c_members in (select all group_test.group_name as gn,member_of_groups.member as mem from group_test, member_of_groups where group_test.id = member_of_groups.group_test_id) loop
IF (group_store = c_members.gn) then
counter := counter + 1;
else
counter := 1;
group_store := c_members.gn;
mem_store := c_members.mem;
end if;
if (counter > 1) then -- Output only groups with more than 1 member
if (counter = 2) then -- Output of the first row
dbms_output.put_line(group_store || ' ' || mem_store || ' 1');
end if;
dbms_output.put_line(c_members.gn || ' ' || c_members.mem || ' ' || counter);
end if;
end loop;
end;
---------- RESULT
group_1 Miller 1
group_1 Smith 2
group_3 Almeida 1
group_3 Walton 2
group_3 McScrooge 3
group_4 Hoover 1
group_4 Brando 2
----------------------------------------- END OF CODE
Now I want to do this with a plain SQL query. Any hints?
Holger
Edited by: user4546673 on 25.11.2009 06:19user4546673 wrote:
Thank you very much,
Sorry, your solution is not exact the same and this is not working:
select group_test.group_name,member_of_groups.member,
row_number() over(partition by group_test.group_name order by member_of_groups.member) rn
from group_test,member_of_groups where group_test.id = member_of_groups.group_test_id and rn > 1;
ORA-00904: "RN": invalid identifierIt is not what you asked originally. Analytical functions are calculated after rows are fetched, so if you wnat rn > 1, you need to wrap it in in-line view:
SQL> select group_test.group_name,member_of_groups.member,
2 row_number() over(partition by group_test.group_name order by member_of_groups.member) rn
3 from group_test,member_of_groups where group_test.id = member_of_groups.group_test_id and rn > 1;
from group_test,member_of_groups where group_test.id = member_of_groups.group_test_id and rn > 1
ERROR at line 3:
ORA-00904: "RN": invalid identifier
select group_name,
member
from (
select group_test.group_name,
member_of_groups.member,
row_number() over(partition by group_test.group_name order by member_of_groups.member) rn
from group_test,
member_of_groups
where group_test.id = member_of_groups.group_test_id
where rn > 1
order by group_name,
rn
GROUP_NAME MEMBER
group_1 Smith
group_3 McScrooge
group_3 Walton
group_4 Hoover
SQL> SY. -
Given this info:
ID Name Class ID Location ID Location Name
101 John Smith 1001 1A Location 1
101 John Smith 2002 2B Location 2
101 John Smith 3003 2B Location 2
101 John Smith 4004 3C Location 3I want to be able to get this output:
ID Name Max Location
101 John Smith Location 2 Using this:
Select id, name, MAX("Amt") from (select id, name,
(case when location_id = '1A' then Count(pidm_key)
when location_id = '2B' then Count(pidm_key)
when location_id = '3C' then Count(pidm_key) else null end) "Amt"
from Table1
group by id, name, location_id)
group by id, name
I get:
ID Name Amt
101 John Smith 2 But of course I want the other output.What is you db version?
you can use the KEEP syntax for the max aggregate in the outer query.
Along the lines of
not syntax checked
MAX(location_name) keep (dense_rank last order by "Amt") -
I have read the responses for missing counters and none seem to apply as I have tried the suggestions. My counter first worked and now it only appears as a question mark on the web page. I have tried deleting, adding, moving and it isn't masked. Help!
G4 iMac Mac OS X (10.4.7)Nothing seems to help. I tried reloading and even went back through iWeb and placed the counter somewhere else and that didn't work so I decided to look at the source code on my web page.
http://web.mac.com/WebObjects/Counter.woa/wa/image?user=wcschwie&page=15
When I went to access that it said that the account is inactive or doesn't exist. I use my .Mac all the time and it is current through January 2007.
Very annoying....
G4 iMac Mac OS X (10.4.7) -
How do i delete my count?
I really want to delete my count, someone else do this count
Sorry, I do not understand what you are asking; do you want to cancel a subscription?
-
<p>
I have a web visit counter program: counter.jsp<br>
It runs everytime a user visit the website, and
records today's date, today's visit number, total visit number
in a text file: counter.txt<br>
The problem is that the total visit number is sometimes initialize to 1.<br>
What's the cause of the problem? Is it related with threading issue?<br>
Any help will be appreciated. thank you.<br>
<p>
############<br>
# counter.jsp #<br>
############<br>
<p>
<code><pre>
<%@ page contentType="text/html; charset=euc-kr" %>
<%@ page import="java.io.*,java.util.*" %>
<%
String strNowDay = "";
String strTempDay = "";
int intTodayCount = 0;
int intTotalCount = 0;
int intCurrentCount = 0;
BufferedReader reader = null;
PrintWriter writer = null;
File fileCounter = null;
String counterPath = application.getRealPath("/counter.txt");
Calendar now = Calendar.getInstance();
strNowDay = Integer.toString(now.get(Calendar.YEAR)) + Integer.toString(now.get(Calendar.MONTH) + 1) +Integer.toString(now.get(Calendar.DATE));
try {
fileCounter = new File(counterPath);
if (fileCounter.exists()){
reader = new BufferedReader(new FileReader(fileCounter));
String strCurrentString = reader.readLine();
if (strCurrentString == null){
writer = new PrintWriter(new FileOutputStream(fileCounter));
writer.println(strNowDay);
writer.println(1);
writer.println(1);
writer.println("end"); //
writer.close();
}else{
strTempDay = strCurrentString;
intTodayCount = Integer.parseInt(reader.readLine());
intTotalCount = Integer.parseInt(reader.readLine());
reader.close();
if(session.getAttribute("count") == null || session.getAttribute("count").equals("")){
if(strNowDay.equals(strTempDay)) {
intTodayCount = intTodayCount + 1;
intTotalCount = intTotalCount + 1;
}else{
intTodayCount = 1;
intTotalCount = intTotalCount + 1;
session.setAttribute("count", "true");
}else{
if(!strNowDay.equals(strTempDay)) {
intTodayCount = 1;
intTotalCount = intTotalCount + 1;
writer = new PrintWriter(new FileOutputStream(fileCounter));
writer.println(strNowDay);
writer.println(intTodayCount);
writer.println(intTotalCount);
writer.close();
}catch(IOException e){
System.out.println(e);
}finally{
%>
</pre></code>
Message was edited by:
eastseaThomas A Reed wrote:
Note that counters are a bit out-of-fashion these days. Visitors to your site don't care, so it's for your benefit only, but you can get the same information from the logs on your web site.
Data and statistical tracking can be extremely beneficial. Certainly does not need to be visible as Thomas A Reed stated above. Not all hosting providers (especially the large monsters, one example GoDaddy) supply something as sophisticated as a cPanel Control Panel, this is where 3rd party stat trackers are an invaluable asset.
Hope this helps. -
Hi Friends,
I have reqmnt like below
Matplant count for Stock using (A/B)-100 <-100
Matplant count = Counter keyfigure
A, B are keyfigures and A = StockXYZ and B = Stock Standard.
how do i count matplant for stock using that formula.. please throw some lights on this.
Thanks for the support...
Edited by: S R on Feb 9, 2009 5:40 PMHi,
Finally you want to count the values in the following formula is it right?
If (A/B)-100 < 100 then
Count = 1
Else
count = 0
As per my understading the abovev one is correct. Yes?
Then in this case then you can calculate as per my previous post, don't do all the calculations in the same step, go by step by step as I told. Then finally you get the values in column - E. i.e. (A/B)-100.
So in Column F do the calculation using formula.
( column - E < 100 ) * 1
or else you can use DataFunction and use Value = 1, if operand <> 0, otherwise 0
Thanks
Reddy -
Hi everobody, I use modelsim to simulation my description. I would like to count pulses (clk) when pwm_out is high. How to do this ? I attached file with print screen of my simulation. Thanks for fast reply! Best regardsLukee
Hi, I would synchronize the process to the clk explicitely...Oki, asnychronous reset could be a bad idea ;-) process (clk, rst) variable count : integer range 0 to 20000;
begin
if(rst = '1') then
-- State machine count := 0; elsif(clk'event and clk = '1') then
if pwm_out = '1' then count := count + 1;
else if (count > 0) then report "count =" & integer'image(count);
count := 0;
end if;
end if;
end if;
end process;
Kai -
Hi,
These are the inputs given through an internal tabe in a report.
ii001 2380 wt00 global data missing
ii001 2380 wt00 global data missing
ii001 2380 wt00 material not found
ii002 2380 wt10 missing partner detail
ii002 2380 wt10 missing partner detail
Output should display as
ii001 2380 wt00 global data missing 2
ii001 2380 wt00 material not found 1
ii002 2380 wt10 missing partner detail 2
ie it shoud count the error messages which are same and display the count.
How to apply the logic.
regards,
Manisay you have internal table itab1 and is1.
declare a work area of same type IS_TEMP.
declare another workarea of same type say IS2 with an extra field count.
data : gv_count type i value '1'.
now.
sort itab by field1 field 2. "all fields
loop at itab1 into is1.
if is1 = is_temp.
count = count + 1.
else.
count = 1.
endif.
is_temp = is.
move corresponding is1 to is2.
append is2 to itab2.
endloop.
now itab2 holds what you need. -
Can someone pls help me with this code
The method createScreen() creates the first screen wherein the user makes a selection if he wants all the data ,in a range or single data.The problem comes in when the user makes a selection of single.that then displays the singleScreen() method.Then the user has to input a key data like date or invoice no on the basis of which all the information for that set of data is selected.Now if the user inputs a wrong key that does not exist for the first time the program says invalid entry of data,after u click ok on the option pane it prompts him to enter the data again.But since then whenever the user inputs wrong data the program says wrong data but after displaying the singlescreen again does not wait for input from the user it again flashes the option pane with the invalid entry message.and this goes on doubling everytime the user inputs wrong data.the second wrong entry of data flashes the error message twice,the third wrong entry flashes the option pane message 4 times and so on.What actually happens is it does not wait at the singlescreen() for user to input data ,it straight goes into displaying the JOptionPane message for wrong data entry so we have to click the optiion pane twice,four times and so on.
Can someone pls help me with this!!!!!!!!!
import java.util.*;
import javax.swing.*;
import javax.swing.event.*;
import java.awt.*;
import java.awt.event.*;
import java.text.*;
import java.util.*;
public class MainMenu extends JFrame implements ActionListener,ItemListener{
//class
FileReaderDemo1 fd=new FileReaderDemo1();
FileReaderDemo1 fr;
Swing1Win sw;
//primary
int monthkey=1,counter=0;
boolean flag=false,splitflag=false;
String selection,monthselection,dateselection="01",yearselection="00",s,searchcriteria="By Date",datekey,smonthkey,invoiceno;
//arrays
String singlesearcharray[];
String[] monthlist={"Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sept","Oct","Nov","Dec"};
String[] datelist=new String[31];
String[] yearlist=new String[100];
String[] searchlist={"By Date","By Invoiceno"};
//collection
Hashtable allinvoicesdata=new Hashtable();
Vector data=new Vector();
Enumeration keydata;
//components
JButton next=new JButton("NEXT>>");
JComboBox month,date,year,search;
JLabel bydate,byinvno,trial;
JTextField yeartext,invtext;
JPanel panel1,panel2,panel3,panel4;
JRadioButton single,range,all;
ButtonGroup group;
JButton select=new JButton("SELECT");
//frame and layout declarations
JFrame jf;
Container con;
GridBagLayout gridbag=new GridBagLayout();
GridBagConstraints gc=new GridBagConstraints();
//constructor
MainMenu(){
jf=new JFrame();
con=getContentPane();
con.setLayout(null);
fr=new FileReaderDemo1();
createScreen();
setSize(500,250);
setLocation(250,250);
setVisible(true);
//This is thefirst screen displayed
public void createScreen(){
group=new ButtonGroup();
single=new JRadioButton("SINGLE");
range=new JRadioButton("RANGE");
all=new JRadioButton("ALL");
search=new JComboBox(searchlist);
group.add(single);
group.add(range);
group.add(all);
single.setBounds(100,50,100,20);
search.setBounds(200,50,100,20);
range.setBounds(100,90,100,20);
all.setBounds(100,130,100,20);
select.setBounds(200,200,100,20);
con.add(single);
con.add(search);
con.add(range);
con.add(all);
con.add(select);
search.setEnabled(false);
single.addItemListener(this);
search.addActionListener(new MyActionListener());
range.addItemListener(this);
all.addItemListener(this);
select.addActionListener(this);
public class MyActionListener implements ActionListener{
public void actionPerformed(ActionEvent a){
JComboBox cb=(JComboBox)a.getSource();
if(a.getSource().equals(month))
monthkey=((cb.getSelectedIndex())+1);
if(a.getSource().equals(date)){
dateselection=(String)cb.getSelectedItem();
if(a.getSource().equals(year))
yearselection=(String)cb.getSelectedItem();
if(a.getSource().equals(search)){
searchcriteria=(String)cb.getSelectedItem();
public void itemStateChanged(ItemEvent ie){
if(ie.getItem()==single){
selection="single";
search.setEnabled(true);
else if (ie.getItem()==all){
selection="all";
search.setEnabled(false);
else if (ie.getItem()==range){
search.setEnabled(false);
public void actionPerformed(ActionEvent ae){
if(ae.getSource().equals(select))
if(selection.equals("single")){
singleScreen();
if(selection.equals("all"))
sw=new Swing1Win();
if(ae.getSource().equals(next)){
if(monthkey<9)
smonthkey="0"+monthkey;
System.out.println(smonthkey+"/"+dateselection+"/"+yearselection+"it prints this");
allinvoicesdata=fr.read(searchcriteria);
if (searchcriteria.equals("By Date")){
System.out.println("it goes in this");
singleinvoice(smonthkey+"/"+dateselection+"/"+yearselection);
else if (searchcriteria.equals("By Invoiceno")){
invoiceno=invtext.getText();
singleinvoice(invoiceno);
if (flag == false){
System.out.println("flag is false");
singleScreen();
else{
System.out.println("its in here");
singlesearcharray=new String[data.size()];
data.copyInto(singlesearcharray);
sw=new Swing1Win(singlesearcharray);
public void singleinvoice(String searchdata){
keydata=allinvoicesdata.keys();
while(keydata.hasMoreElements()){
s=(String)keydata.nextElement();
if(s.equals(searchdata)){
System.out.println(s);
flag=true;
break;
if (flag==true){
System.out.println("vector found");
System.exit(0);
data= ((Vector)(allinvoicesdata.get(s)));
else{
JOptionPane.showMessageDialog(jf,"Invalid entry of date : choose again");
public void singleScreen(){
System.out.println("its at the start");
con.removeAll();
SwingUtilities.updateComponentTreeUI(con);
con.setLayout(null);
counter=0;
panel2=new JPanel(gridbag);
bydate=new JLabel("By Date : ");
byinvno=new JLabel("By Invoice No : ");
dateComboBox();
invtext=new JTextField(6);
gc.gridx=0;
gc.gridy=0;
gc.gridwidth=1;
gridbag.setConstraints(month,gc);
panel2.add(month);
gc.gridx=1;
gc.gridy=0;
gridbag.setConstraints(date,gc);
panel2.add(date);
gc.gridx=2;
gc.gridy=0;
gc.gridwidth=1;
gridbag.setConstraints(year,gc);
panel2.add(year);
bydate.setBounds(100,30,60,20);
con.add(bydate);
panel2.setBounds(170,30,200,30);
con.add(panel2);
byinvno.setBounds(100,70,100,20);
invtext.setBounds(200,70,50,20);
con.add(byinvno);
con.add(invtext);
next.setBounds(300,200,100,20);
con.add(next);
if (searchcriteria.equals("By Invoiceno")){
month.setEnabled(false);
date.setEnabled(false);
year.setEnabled(false);
else if(searchcriteria.equals("By Date")){
byinvno.setEnabled(false);
invtext.setEnabled(false);
monthkey=1;
dateselection="01";
yearselection="00";
month.addActionListener(new MyActionListener());
date.addActionListener(new MyActionListener());
year.addActionListener(new MyActionListener());
next.addActionListener(this);
invtext.addKeyListener(new KeyAdapter(){
public void keyTyped(KeyEvent ke){
char c=ke.getKeyChar();
if ((c == KeyEvent.VK_BACK_SPACE) ||(c == KeyEvent.VK_DELETE)){
System.out.println(counter+"before");
counter--;
System.out.println(counter+"after");
else
counter++;
if(counter>6){
System.out.println(counter);
counter--;
ke.consume();
else
if(!((Character.isDigit(c) || (c == KeyEvent.VK_BACK_SPACE) || (c == KeyEvent.VK_DELETE)))){
getToolkit().beep();
counter--;
JOptionPane.showMessageDialog(null,"please enter numerical value");
ke.consume();
System.out.println("its at the end");
public void dateComboBox(){
for (int counter=0,day=01;day<=31;counter++,day++)
if(day<=9)
datelist[counter]="0"+String.valueOf(day);
else
datelist[counter]=String.valueOf(day);
for(int counter=0,yr=00;yr<=99;yr++,counter++)
if(yr<=9)
yearlist[counter]="0"+String.valueOf(yr);
else
yearlist[counter]=String.valueOf(yr);
month=new JComboBox(monthlist);
date=new JComboBox(datelist);
year=new JComboBox(yearlist);
public static void main(String[] args){
MainMenu mm=new MainMenu();
public class WindowHandler extends WindowAdapter{
public void windowClosing(WindowEvent we){
jf.dispose();
System.exit(0);
}Hi,
I had a similar problem with a message dialog. Don't know if it is a bug, I was in a hurry and had no time to search the bug database... I found a solution by using keyPressed() and keyReleased() instead of keyTyped():
private boolean pressed = false;
public void keyPressed(KeyEvent e) {
pressed = true;
public void keyReleased(KeyEvent e) {
if (!pressed) {
e.consume();
return;
// Here you can test whatever key you want
//...I don't know if it will help you, but it worked for me.
Regards.
Maybe you are looking for
-
Is there any way to reinstall google maps as the new map app is at best dire
Since the latest iOS 6 to say the maps application is dire would be an understatment, My house no longer exists and a new street has appeard behind where i live , i used to use the application all the time as im a mobile mechanic and need a reliable
-
IPad 2 hosed after trying to load 5
JUst tried loading 5 on iPad. It said I had to restore, Idid that and now its hosed. iTunes won't see it and the iPad itself is stuck on the apple screen. Anyone have a clue how to get this working?
-
Apple Remote Desktop 3 and Real VNC
Just wanted to post an FYI, that recently I found out VNC (Real VNC) Server & Viewer were conflicting with ARD 3.2 in terms of screen sharing/control. All other connections were fine. (e.g. chat, message, package install, etc..) For me to regain a su
-
Install window pops up ever time I open the browser.
-
Hi, I have developed an application for Single Sign on administration, I want to add new partner applications using my app, but I have to insert the SITE_TOKEN field in the ORASSO table. Any Idea how to get it?. Thanks. Carlos