Questions tagged as 'sql'

1
answer

Modify SQL query to get response with desired structure

I am trying to create a query that allows me to show (in different columns) the budget for each month. This is the query I'm using: SELECT TOP 12 CL.Cliente_DS, EJE.Ejecutivo_DS, DS.Disciplina_DS, LN.Linea_Negocio_D...
asked by 07.03.2018 / 17:18
1
answer

sql query returns incorrect result

Hi guys I have the following query, I'm working in PostgreSQL, and my base is a survey applied to people in certain areas, basically you need to make an analysis that if you have some kind of animal this family, put the number one (as if it were...
asked by 07.03.2018 / 16:59
1
answer

the sql statement in postgres, is the prefix "public" necessary?

I am working with PHP and PDO connecting to a postgresql database, I have a doubt, since something that I do not expect is happening. $pdo = new PDO('pgsql:dbname=db_pdo_postgresql; host=localhost;', 'juan_postgres...
asked by 18.02.2018 / 14:00
1
answer

If I have such a SQL query using WITH (CTE) can I get the same results without it?

I was doing a view that uses WITH, and it turns out that the Web Client Compiere does not get along with the views with WITH .. (they told me) Then I wanted to know if I can reach the same results in the data without using WITH. If you hav...
asked by 23.02.2018 / 15:31
1
answer

Query SQl with inner join to filter data based on the user that enters the system

Teng a Database with the following scheme: The user belongs to an establishment, the establishment belongs to a municipality, the department has many municipalities and the municipality has many cantons, so I want an SQL query that returns...
asked by 26.02.2018 / 15:55
1
answer

How to get a single record of a JOIN between 2 tables?

I happen to have 2 tables. One is the "main" table and another table where data is saved according to what is recorded in table 1. Table 1 will only have one record, while table 2 can have 2 or more records that depend on the record that was mad...
asked by 26.02.2018 / 01:55
1
answer

Consult several tables

I am using the following code but it does not work for me. I'm trying to bring information from 3 tables: $result = mysqli_query($con,"SELECT a.ID,a.proveedor,a.peso,a.fecha,b.ENTRADA,b.cajas,b.peso,b.pagado,c.ENTRADA,c.monto FROM a entradas...
asked by 30.01.2018 / 07:31
1
answer

Database Consultation

I have a table of bank movements of many users that can be repeated throughout it. The table has different fields such as Box, UserName, IDN, Date, Amount ... What I want to do is a ranking of boxes with more users sorted by the DNI (without...
asked by 31.01.2018 / 10:51
1
answer

Error when trying to insert data into a table (Trigger)

I am new here and I come to ask you where is the error in the code (exact match returns ..) since I am eating my head and I still can not find it. It turns out that the Trigger works with the first two inserts in the Call table but in the third...
asked by 13.01.2018 / 14:37
2
answers

I can not add the foreign key of the user table

Before the user table create the corresponding tables to add the foraneas create table acreditacion(idacre int not null auto_increment, nomacre varchar(50) not null, primary key(idacre)) ENGINE = I...
asked by 14.03.2018 / 00:24