Questions tagged [count]
COUNT : an aggregate SQL function that is used to count the number of rows.
449 questions
0 votes
1 answer
77 views
Sqlite count while also grouping?
select * from tblA a left join tblB b on b.id = a.bId group by a.bId If I group based on a column, I get only the first record of the records that have same bID value. Is there a way to also ...
-1 votes
1 answer
197 views
What happened to Oracle's COUNTDISTINCT() function? [closed]
I need the count of unique values, and am trying to use Oracle's COUNTDISTINCT() function to obtain that: select COUNTDISTINCT(a.m_label) from user_rep a, user_group_rep b, trn_grp_rep c ...
2 votes
2 answers
244 views
sum() of aggregate count()?
I have a query where I pull the domain portion from email addresses out of a column and then count how many users from which domain I have. How do I get the total count (all users over all domains) in ...
0 votes
2 answers
271 views
How to get records which meet conditions stored in another tables
Problem: How to get passed requirements where there are 4 tables in such relation requirements->links<-test_cases test_cases->results<-result Scenario: Table1 - requirements req_id ...
1 vote
1 answer
164 views
PostgreSQL - Sum all row that satisfy a condition into a single row
I'm trying to extract some statistics from a Postgres database and I made this query: SELECT city, job_count, TO_CHAR(job_count * 100 / SUM(job_count) OVER (), '90D00%') AS job_share FROM ( ...
2 votes
1 answer
79 views
Query for single return meeting multiple criteria and values
I'm trying to figure out a way to count an ID once when multiple criteria are met in one column while displaying a total of the same criteria in another column. The criteria for the first column can ...
0 votes
2 answers
97 views
Mysql count Same Two or More Same Record as One and Summarize It
Good Afternoon all, I have two same data record or more in MySql table. How i can counting the same data as one and zero if have only one data based on flag status pair. Below is an example of data: ...
0 votes
1 answer
194 views
Optimized count for large table using triggers, views, or external cache
I have a public API method that calls a Postgres (14) database and returns a paginated list of rows belonging to a user along with a total count and page index. The count is very costly to perform (...
3 votes
5 answers
3k views
How to write an SQL query where the count of 2 different attributes is the same?
I created two different tables and then decided to put them (=) to each other however, what I am confused about is whether (=) is allowed to be used like that. I tried using IN but I didn't know where ...
1 vote
2 answers
517 views
Extremely slow COUNT query on Aurora Postgress Serverless v2 with two tables
I'm designing a web application where sellers can offer their cars, banks provide various financing offers (e.g. 36 months, 25% downpayment, 25% final payment). Buyers come to this web app and they ...
0 votes
0 answers
67 views
How to Count calculated work hours in one month for each labors
Good Day. I have some data like bellow id name in out 1 lala 2023-09-29 07:00:00 2023-09-29 17:00:00 2 lili 2023-09-29 07:30:00 2023-09-29 16:00:00 1 lala ...
1 vote
1 answer
103 views
MySql count using and still show all data even using where clause
Good Afternoon, How i can show all data when using count and where clause in MySql. In my case, I have master data like pict at below. and i using this query to show count the data. SELECT body, ...
1 vote
1 answer
388 views
SELECT / DELETE rows where consecutive null value count is greater than N
I have a table of the following structure, where all columns except the last are non-null: ID receiver send_time recv_time 1 A 00:00:00 00:00:01 2 A 00:00:01 NULL 3 A 00:00:02 NULL 4 A 00:00:03 NULL 5 ...
0 votes
2 answers
897 views
Comparing 2 count columns with case
I have 2 tables, size and cost. My query does a count with a greater than comparison of cost and counts different sizes. table1: size u table2: cred t Here is my query: select u.size as size ,...
2 votes
3 answers
97 views
Find percentage based on values for each ID
I have table1 with 2 ID's and 2 values per ID (Y,N). I can count the values by the following query: select id ,count(*) as "total" ,choice from table1 where id in (1,8) group by id, choice ...