Questions tagged as 'sql'

1
answer

Total sales per month grouped by seller

I need to bring a listing of executives and their total sales per month, this is all regardless of having a sale in the month or not. For years I've been focused on front-end and never done anything with sql, can you help me? vendedor jan...
asked by 02.11.2018 / 23:23
1
answer

Count / Dense_rank grouped sql

I'm trying to group the rows by group in 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...
asked by 23.05.2018 / 16:17
1
answer

How to catch mysql (duplicate entry) error and display a message on screen for the user, using codeigniter?

How to catch the error of mysql (duplicate entry) and display a message on the screen to the user, using codeigniter?    Error Number: 1062       Duplicate entry '123456' for key 'process'       INSERT INTO processo ( nprocesso...
asked by 02.05.2018 / 21:53
2
answers

Concatenate the field and group the remainder

I have the following query: SELECT finempe.data_empenho , finempe.num_empenho , finhisem.quantidade , finhisem.historico , finhisem.valor , finhisem.valor_total FROM finempe RIGHT JOIN finhisem ON (finhis...
asked by 26.04.2018 / 18:14
2
answers

Cross two tables and link the line one with another, forming a third

Good afternoon, fellow programmers. I came across the following problem: I have two tables, one with applicants, and one with vacancies. I need a query that crosses the two tables, and get the first available slot and give it to the first req...
asked by 08.05.2018 / 18:40
1
answer

Select period between times

I'm trying to set up a sql to check if there is any record between informed times, but it's not coming out, I've done some tests but I have not been successful. For example, a bank record that contains these two times, as initial and f...
asked by 06.03.2018 / 00:37
2
answers

Hello everyone. Can anyone tell me why the result of the query below is bringing in the first 4 records the Zeroing Balance?

Can anyone tell me why the result of the query below is bringing the Balance to zero in the first 4 records? I'm calculating the inputs plus the outputs. Calculates correctly if there are values in the two columns, but when there is no value in...
asked by 02.03.2018 / 21:44
4
answers

Compare one field of a table with another table

I am trying to create a query in SQL Server to know if the city that was filled at the time of registration that the person did, is equal to a city field of another table that already has all the municipalities of Brazil, how can I do This?...
asked by 27.12.2017 / 11:43
1
answer

How to auto increment in MySQL without declaring the columns in INSERT?

I noticed that when I have a column with auto_increment , I have to declare the columns in INSERT . For example, I created this test table: create table teste( id int auto_increment, nome varchar(100) not null, valor decimal(5,2...
asked by 30.07.2018 / 01:52
1
answer

Performance with Exists

One colleague mentioned that when doing EXISTS in SQL, it is recommended to use DISTINCT 1 to improve performance. For example, instead of doing: SELECT * FROM CLIENTES WHERE NOT EXISTS (SELECT CODCLI...
asked by 03.04.2018 / 15:23