oracle - SQL group by and aggregate function -


i have following table structure sample data (only columns of interest listed). want query return # of bsp_id's completed # of up_id's.

bsp_id | up_id | status_flag 1256     15      completed 1232     1       completed 1216     15      completed 1216     1       completed 1235     1       completed 

and result of query should be

count(bsp_id) | count(up_id)     1                 2     3                 1  

you need nested query. should work:

the internal query:

select bsd_id, count(*) c mitable status_flag='completed' group bsd_id 

results:

1256, 1

1232, 1

1216, 2

1235, 1

the complete query:

select count(*), t.c (select bsd_id, count(*) c mitable status_flag='completed' group bsd_id) t group t.c 

results:

1, 2

3, 1


Comments

Popular posts from this blog

python - TypeError: start must be a integer -

c# - DevExpress RepositoryItemComboBox BackColor property ignored -

django - Creating multiple model instances in DRF3 -