Skip to main content
Announcements
July 15, NEW Customer Portal: Initial launch will improve how you submit Support Cases. IMPORTANT DETAILS
cancel
Showing results for 
Search instead for 
Did you mean: 
mimivan
Contributor II
Contributor II

Display count

I am new  to QS . I have 2 tables with same key of a and want to get the count of fields.  Do I need to do a join or any other way? Thanks. 

table1:
Load * Inline [
a,b
1,2,
2,2
3,3,
4,2
];

table 2:
Load * Inline [
a,d
1,yy1
1,yy2
2,dd3
2,dd4
3, xx1
4, zz1

];

Want to get result of count so i can display on screen the count of b like this. 

a, count of b
1, 2
2, 3
3, 1
4, 1

Labels (1)
1 Solution

Accepted Solutions
sidhiq91
Specialist II
Specialist II

@mimivan Please see the below script. 

NoConcatenate
table1:
Load * Inline [
a,b
1,2
2,2
3,3
4,2
];


left join (table1)
Load * Inline [
a,d
1,yy1
1,yy2
2,dd3
2,dd4
3, xx1
4, zz1
];

Main:
Load a,
Count(b)
Resident table1
Group by a;

Drop table table1;

Exit Script

If this resolves your issue, please like and accept it as a solution.

View solution in original post

3 Replies
sidhiq91
Specialist II
Specialist II

@mimivan Please see the below script. 

NoConcatenate
table1:
Load * Inline [
a,b
1,2
2,2
3,3
4,2
];


left join (table1)
Load * Inline [
a,d
1,yy1
1,yy2
2,dd3
2,dd4
3, xx1
4, zz1
];

Main:
Load a,
Count(b)
Resident table1
Group by a;

Drop table table1;

Exit Script

If this resolves your issue, please like and accept it as a solution.

MayilVahanan

HI

Based on ur scenario, both A & B occur in the same table. So no need to join the tables.
And also, can u explain how Count of b is "3" in the expected results?

Thanks & Regards, Mayil Vahanan R
Please close the thread by marking correct answer & give likes if you like the post.
mimivan
Contributor II
Contributor II
Author


Thanks for pointing out my typo in the sample. Want to get result of count of d not b, so i can display:

 a, count of d
 1, 2
 2, 2
 3, 1
 4, 1