Questions tagged as 'query'

1
answer

Calculate average of the value of registrations up to 100km sql

I'm doing a query that brings the average values, as long as the distance is up to 90km: SELECT avg(valor),(6371 * acos( cos( radians(-23.2632227) ) * cos( radians( lat ) ) * cos( radians( lng ) - radians(-45.9414303) ) + sin( radians(-23....
asked by 25.05.2017 / 16:59
2
answers

Customers who bought in one year but not in another [closed]

I need to make a select that brings me which customers I bought in 2016 and did not buy in 2017 and vice versa. This is my select: SELECT tc.'cod-emitente' AS CODIGO, tc.'nome-emit' AS CLIENTE, fg.'ano' AS ANO FROM tb_clientes tc LEFT JOI...
asked by 26.05.2017 / 18:54
3
answers

Problem when ordering sql with orderby Date in postgresql

I have the following Query that results in joining the total sum of an account and the plots select sum(total) as total, datavencimento from ( select sum (con_valoraserpago) as total, to_char(con_datavencimento...
asked by 09.08.2017 / 01:25
1
answer

Alternative to the use of view variables in mysql

I need to create a view that gets the percentage of each product in relation to the total of products, I made the query below and it works as a normal select: set @total := (SELECT round(sum(gin.Caixa_9L /1000),4) FROM gin where sales_channel...
asked by 10.04.2017 / 15:20
2
answers

Return the shortest date within the Select

I have the following table: CREATE TABLE [dbo].[Crm_man]( [id] [int] IDENTITY(1,1) NOT NULL, [nCRM] [int] NULL, [cliente_CRM] [int] NULL, [item_CRM] [int] NULL, [qnt_CRM] [int] NULL, [descri_CRM] [varchar](max) NULL, [descri_NF] [varchar](max)...
asked by 12.05.2017 / 18:59
1
answer

MYSQL - Query adding 8 identical tables

Good afternoon, I'm pretty new to MYSQL, basically I'm learning about searching the net, but there was an issue that I could not solve. I have about 6 tables, in each I have 10 fixed and identical entries in the field ID and TYPE, which do no...
asked by 10.02.2017 / 19:55
1
answer

Problems with Query Builder in Laravel 4.2

Hello, I am having trouble generating a query using the Query Builder of Laravel 4.2 , the difficulty arises from the need for resulting queries in the database to be inside of parentheses, below is the desired query: select * from 'EV_R...
asked by 05.12.2016 / 20:12
1
answer

How to modify this query to get the desired result in Codeigniter?

I have a SQL that returns me the following:    1: Hacker And Cars       OU       2: Food I need to get it back:    1: Hacker       E       2: Automotive OR Food The code I have so far is: if(!$final['termo'] == null)...
asked by 19.11.2016 / 15:58
3
answers

Delete Report with months reset

I have a query in which I take monthly deposited values, it takes everything that it has in the base and shows the months that were inserted in the database. I would like to do different would like it to also show the months that did not have...
asked by 08.11.2016 / 16:19
1
answer

Preview input field does not work

My browser is not displaying the image. Something wrong with this code? $(document).ready(function () { $("input[name='fun_imagem']").change(function () { readImage($(this)); }); }); function readImage(input) {...
asked by 02.09.2016 / 22:54