Questions tagged as 'count'

4
answers

Performance of COUNT (*) and COUNT (1)

What is the difference between COUNT(1) and COUNT(*) in an SQL query. For example: SELECT COUNT(1) FROM USUARIOS; and SELECT COUNT(*) FROM USUARIOS; Is there any difference in interactions within SBGD? Which would...
asked by 20.06.2017 / 19:41
2
answers

Count friends in common using LEFT JOIN

I have the following tables: users : id | usuario | pnome | snome | foto 1 | Igor | Igor | Souza | perfil.png 2 | Alex | Alex | Khal | foto.jpg 3 | Maria | Maria | Silva | foto.png Friendships : id | amigo1 | amigo2 | e...
asked by 03.05.2016 / 18:05
2
answers

SQL SERVER Data counting of a record

I came across the following situation: The table below is a checklist and has a column of covenants, the others are questions answered with yes (1), no (0) and noFill (null or 9). I wanted to tell in each agreement how many of the questions...
asked by 20.09.2018 / 15:49
1
answer

Doubt in the method of using Distinct and Count together!

I have a table requests as the example below: Id | Cliente | Status 1 | XPTO | Proposta 2 | ABCD | Proposta 3 | XPTO | Venceu 4 | XPTO | Perdeu And I want to present a result like this: Cliente | Status | Qtd XPTO...
asked by 04.08.2016 / 19:24
1
answer

Count in two tables

I'm having trouble counting neighborhood items. I need to list all of the neighborhoods in City X and show the available cars and motorcycles items. In the example I just used a city for easy illustration. I used group by and left join...
asked by 31.01.2015 / 22:38
1
answer

How to add unmatched parcels with SQL?

I have 3 tables faturas , parcelas and pagamentos . Now I need to mount an SQL to count the parcels that are not removed. I already tried SUM(CASE but it did not work. Structure of the faturas table: id_fa t...
asked by 24.01.2016 / 13:56
3
answers

How to sum the count result of different tables in SQL Server?

How to add the count result of different tables in SQL Server? Example: Table WORKS has 755614 Records SELECT count(*) from OBRAS; TITLES table has 85106 Records SELECT count(*) from TITULOS; AUTHORS table has 19029 Records...
asked by 29.12.2017 / 13:29
2
answers

Sort Mysql results using two tables

This is the following, I have two tables, one called topic and another comments (which has a foreign key of the table topics), I wanted to list the topics by ordering them by the amount of comments from each. I broke my head and could not do it,...
asked by 12.01.2017 / 14:43
2
answers

Count with null value return zero

I made an insert into a table and now I need to make a select in that table by making a count in a given column. The question is that this column (which I gave the request name) has null value for some situations and when I do the count, I wo...
asked by 31.10.2018 / 19:34
2
answers

Doubt referring to Count in SQL command

I need to count the amount of supplies available in stock according to your codigoSuprimento , so I created the following sql command: select count(codigosuprimento) quantidade, codigosuprimento from public.estoque where usado = '0' grou...
asked by 22.08.2017 / 16:11