Most voted "count" questions
81 questions
Sort by count of
-
14
votes4
answers2496
viewsPerformance of COUNT(*) and COUNT(1)
What’s 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 of interactions within…
-
6
votes2
answers166
viewsWhat is the Countable interface for in PHP?
I saw a certain class whose statement was that way: class Collection implements Countable {} I realized she was implementing Countable, but I didn’t understand what this implementation was doing…
-
6
votes2
answers361
viewsCount 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 |…
-
6
votes1
answer499
viewsCOUNT(*) x COUNT(1) x COUNT(id)
I would like to understand better about the difference between these ways of using the counter: select COUNT(*) from tabela select COUNT(1) from tabela select COUNT(id) from tabela This question…
-
5
votes2
answers76
viewsSQL SERVER Counting the data 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 semPreenchimento(null or 9). I wanted to…
-
4
votes1
answer1365
viewsCountdown in two tables
I’m having trouble counting items pertaining to neighborhoods. I need to list all the neighborhoods of the city X and show the items available cars and motorcycles. In the example I only used one…
-
4
votes1
answer197
viewsHow to add unpaid installments with SQL?
I have 3 tables faturas, parcelas and pagamentos. Now I need to mount an SQL to count the installments that are not paid. I have tried a SUM(CASE but it didn’t work out. Table structure faturas:…
-
4
votes1
answer1453
viewsDoubt in the method of using Distinct and Count together!
I have a requested table 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 |…
-
4
votes3
answers2090
viewsHow to add Count output from different tables in SQL Server?
How to add up the result of Count of different tables in SQL Server? Example: Table WORKS has 755614 Records SELECT count(*) from OBRAS; Table TITLES has 85106 Records SELECT count(*) from TITULOS;…
-
3
votes0
answers2256
viewsRegressive chronometer but when it reaches zero starts again?
I adapted a regressive timer that I found here on the net and adapted to what I want. It is to be used in a cycling race and in a time trial stage where cyclists depart every 2 minutes. It works but…
-
3
votes2
answers141
viewsSort Mysql results using two tables
is the following, I have two tables, a so-called topical and other comments(which has a foreign key from the topical table), I wanted to list the topics by sorting them by the amount of comments…
-
3
votes1
answer1467
viewsUsing recursion to count the number of times a number appears in a list
I created a recursive algorithm to count the number of times a certain number n appears in a list ls. It seemed to work if the list ls is quite small (between 10 and 100), but if it’s big, like…
-
3
votes2
answers125
viewsDoubt regarding Count in SQL command
I need to count the amount of supplies available in stock according to your codigoSuprimento, for this I created the following sql command: select count(codigosuprimento) quantidade,…
-
3
votes1
answer61
viewsHibernate Cache with select Count
Hello! I have a JPQL consultation, with count: public Long quantidadeFaturasAbertasAssinante(Integer idAssin){ return manager.createQuery("select count(f) from Fatura f where f.dataLiquidacao IS…
-
3
votes2
answers417
viewsCount with null value return zero
I made an Insert in a table and now I need to make a select in this table making a Count in a given column. The point is that this column (which I gave the request name) has null value for some…
-
3
votes1
answer23
viewsHow to count records in the Onetomane relation returning zero when there is no match
Friends, I am trying to make an app to control investments in shares. In DB of this app I have the table portfolio and active table. I need to make a select that returns to me the active portfolios…
-
2
votes1
answer1230
viewsCount and Display Records from different PHP/MYSQL tables
GOOD AFTERNOON. I am creating a report to tell and display: - the number of men and women (table: Customer) who made booking (table booking) at a hotel in a given period of time (passed via form).…
-
2
votes2
answers325
viewsHow can I execute this query with Laravel 5?
How I would perform the following query in Laravel 5: SELECT *, (SELECT COUNT(`anuncios`.`cat-id`) FROM `anuncios` WHERE `anuncios`.`cat-id`=`categoria`.`cat-id`) AS `cat-total` FROM `categoria`…
-
2
votes2
answers3604
viewsSpecified conversion is not valid
I’m making an appointment with LINQ in the DataTable in that code snippet. I have to check if a link already exists for a registered person in the database. My query using the LINQ is working…
-
2
votes3
answers3385
views2 COUNT within a SELECT with LEFT JOIN
I have two tables: users: id | nome | email shipments: id | id_envia | id_recebe Every time a user sends a card (which goes by email) to another user, mark this table, and every time they receive…
-
2
votes1
answer248
viewsSplit sum and Count output in the same Query?
The code below works, but I wanted to know how to do it all query, and if the way I’m riding her is really the best way. $query = Avaliar::select(DB::raw('COUNT(id) as contar'), DB::raw('SUM(nota)…
-
2
votes2
answers179
viewsMysql Count in substrings in the columns of a varchar field
I have the following example table: ID_USER | FRUTAS ----------------------------- 1 | Laranja;Banana;Maçã 2 | Abacaxi;Laranja;Uva 3 | Pera;Laranja;Banana;Melão It would be possible to perform a…
-
2
votes1
answer214
viewsCount and group by day range
SELECT loc.loc_pac as registro, datediff(dd, pac.pac_nasc, getdate()) as 'dias' from loc with (nolock), pac with (nolock), str with (nolock) where loc.loc_pac <> '' and (loc.loc_pac =…
-
2
votes1
answer153
viewsCount/Dense_rank sql grouped
I’m trying to group the lines by group on sqlserver and as a result I want to: CICLO | CODFIL | CODITPROD | ROW 1 | 1 | 10 | 1 11 | 1 | 10 | 2 12 | 1 | 10 | 3 1 | 2 | 10 | 1 11 | 2 | 10 | 2 1 | 3 |…
-
2
votes1
answer834
viewsPython - Count values within another count of values in a dataframe?
I have a df as follows and I need to make a top 10 of the most repeated words in problem and within these selected words do the same within the solution. Obs: the dataframe has more than 20,000…
-
1
votes2
answers229
viewsMysql Query - Count separate table fields
I need to create a view in Mysql where return the following result. Col1 | Col2 Total Tab1 | Total Tab2 I am using UNION in the form below, but the result comes as follows: col1 201 5699 CREATE VIEW…
-
1
votes2
answers44
viewsMake top 10 by checking 3 tables
I have 3 tables: sponsors id | id_patrocinador | id_usuario quotas id | id_user | quantidade users id | nome | login What I need to do is a TOP 10 where I list 10 users who have more sponsored with…
-
1
votes5
answers11915
viewsCount number of Mysql query records in PHP
I made the code below to count the amount of records, but he tells me 1 to 1, I wonder how I can do to add these records and call with an echo. ?> <?php $sql="SELECT id FROM processo"; $return…
-
1
votes1
answer1070
viewsHow to count NULL type values in Mysql
I have a simple table with the answers, in this table I can have answers with value null, 0, 1, 2, 3, ... , only when I count the number of responses with each value these with the value null does…
-
1
votes2
answers853
viewsCOUNT in several tables
I have two tables in my system, and I need to count two columns in the tables. I currently do through a VIEW as follows: CREATE VIEW totais AS (SELECT (SELECT COUNT(publications.id) FROM…
-
1
votes1
answer507
viewsCOUNT AT FIREBASE
Hello, Is it possible to do COUNT (record count) in the firebae database? Because I would like to return in my app the total of occurrences created (ALL of all users) and total per user, but, I do…
-
1
votes1
answer1642
viewsDoubt in select with group by and Count?
I’m making a SQL in 2 tables in Oracle and would like to group the information according to the job code and also count how many people are in that position. I’m using the following SQL: select…
-
1
votes2
answers566
viewsSelect with re occurrences of a period record
I need to know if a record occurred again in a 7-day period. For this, I count with a table that saves the records and the occurrence date. For example: Registro: x | Data: 13/03/2017 Registro: y |…
-
1
votes1
answer44
viewsCount number of occurrences in a log file
I am trying to count the number of occurrences of multiple text patterns in a log file. My code is counting all lines of the file for all text patterns. Where am I going wrong? The log file looks…
-
1
votes1
answer293
viewsHow to count how many fields are empty in the mysql table
I have a land register table with several columns (some of them: id, address, city, proposal, etc) and I would like to count how many fields are empty. For example, the table has a total of 44…
-
1
votes1
answer89
viewsError doing counter via c#
I’m trying to do a pendant counter to my system, only it’s giving error, at the time of calculating, someone could help me? Error in . Count as you can see in the picture below. My Controller public…
-
1
votes2
answers283
viewsCount numbers drawn on a lottery table
I am new to BD studies and I have a table with the results of Lotofácil where I would like to do a Count that looked for, for example, how many times the tens 20 was drawn. I have done several tests…
-
1
votes2
answers72
viewsCount values in multiple related tables
I have 4 tables tbl_Distrito, tbl_Unidade, tbl_Servidor, tbl_Processo. tbl_Distrito: Cod_Distrito, Nome_Distrito tbl_Unidade: Cod_Unidade, Nome_Unidade, Cod_Distrito tbl_Servidor: Cod_Unidade…
-
1
votes1
answer221
viewsCOUNT function with criteria
How do I make this count meet some criteria? ALBERTO CONCLUÍDO | 8 REPROVADO | 3 DUPLICADO | 4 EM ANÁLISE| 5 I need you to return this result to the screen... where: The number represents how many…
-
1
votes1
answer31
viewsConvert percentage
I’m having trouble converting % my code: select veiculos , qtd , trunc(qtd / sum(qtd) over()* 100, 4 ) PERC from ( select ent_datahora_entrada , veiculos , count(*) qtd from ( select…
-
1
votes2
answers49
viewsSQL - WHERE using 2 conditions and AND as conditional - Answer is not the expected result
Good afternoon, doubt is very basic. I am counting items from a single table to two specific "classes" (M and N) within the same column (two possible outputs is what I am calling a "class"). When I…
-
0
votes1
answer1811
viewsCorrect way to return the number of results using Codeigniter
I wrote 2 possibilities to return the number of results using Codeigniter, follows: public function get_num_indicados($id_usuario) { $query = $this->db->query("SELECT count(id_patrocinador) as…
-
0
votes1
answer418
viewsCount the amount of my IF records
IF(Count(UCID)>1,Count(UCID),'0'), it brings me approximately 500 lines of record, being numbers of 2 above, I want to be able to make a COUNT in that IF to present those 500 in a column to part.…
-
0
votes1
answer170
views -
0
votes1
answer200
viewsDoubt group by + SUM function
I have a problem putting together a query in my database mysql for attendance at an event. I have a participating table where I have the participant’s information, and I have the attendees' presence…
-
0
votes0
answers86
viewsSQL-Count for each id
I want to show all student table records - name and number - and then in the right column, show attendance percentage. Let’s see: SELECT nome, numero, ( ( SELECT COUNT(aluno.numero) FROM aluno JOIN…
-
0
votes1
answer166
viewsCount in multiple tables
I have 3 tables I need a query that takes the name of the school, number of classes type A, Qtde of classes type B, Qtde of students who are in classes type A, and Qtde of students who are in…
-
0
votes1
answer138
viewsSelect JOIN + AVG() - Doubt with feedback
I’m solving an exercise but I’m having problems in return: Question: Write the query that returns the supplier’s code, the supplier’s name, the number of products per supplier and the average price…
-
0
votes1
answer15
viewsDisplay prayed results
Good evening I’m creating a referral system, But the query result does not return users with zero indications Here is my select SELECT c.id, c.nome, funcao, area, count(p.cpf_cli) AS quantidade FROM…
-
0
votes1
answer110
views