Android Question sqlite problem / with count ? Group by

FrankDev

Active Member
Licensed User
Longtime User
hi,

I have a sqlite problem

have a table with the following values

Field1, Field2

27256 , 1
27256 , 1
27256 , 1
27256 , 2
27256 , 2

28767, 1
28767, 1
28767, 2

32345, 1
32345, 1


I want to have the number of records when I group by field1 and field2

27256 , 1
27256 , 2
28767, 1
28767, 2
32345, 1

this is how it would be grouped without repetition

so i want to have the result '5

Select ? group by field1, field2

regards
Frank
 

RB Smissaert

Well-Known Member
Licensed User
Longtime User
hi,

I have a sqlite problem

have a table with the following values

Field1, Field2

27256 , 1
27256 , 1
27256 , 1
27256 , 2
27256 , 2

28767, 1
28767, 1
28767, 2

32345, 1
32345, 1


I want to have the number of records when I group by field1 and field2

27256 , 1
27256 , 2
28767, 1
28767, 2
32345, 1

this is how it would be grouped without repetition

so i want to have the result '5

Select ? group by field1, field2

regards
Frank
I think
hi,

I have a sqlite problem

have a table with the following values

Field1, Field2

27256 , 1
27256 , 1
27256 , 1
27256 , 2
27256 , 2

28767, 1
28767, 1
28767, 2

32345, 1
32345, 1


I want to have the number of records when I group by field1 and field2

27256 , 1
27256 , 2
28767, 1
28767, 2
32345, 1

this is how it would be grouped without repetition

so i want to have the result '5

Select ? group by field1, field2

regards
Frank
select count(*) as cnt from
(select distinct field1, field2 from table1)

RBS
 
Upvote 0

mc73

Well-Known Member
Licensed User
Longtime User
B4X:
select count(1) from (select field1,field2 from yourTable group by field1,field2) tblb
B4X:
select count(1) from (select distinct(field1||','||field2) from yourTable) tblb
Try these out, not tested.
 
Upvote 0

FrankDev

Active Member
Licensed User
Longtime User
B4X:
select count(1) from (select field1,field2 from yourTable group by field1,field2) tblb
B4X:
select count(1) from (select distinct(field1||','||field2) from yourTable) tblb
Try these out, not tested.
hi,

thank you very much.
I have already tried the previous example.

Works.
what is the advantage of

count(1)

many
greetings
 
Upvote 0
Top