Questions tagged as 'subconsultas'

2
answers

Problems with max use after count

Dear, I have this query SELECT p.id_pregunta, tr.tipo, COUNT(r.id_respuesta) as cantidad_respuestas FROM encuesta e LEFT JOIN dimension d on e.id_encuesta = d.id_encuesta_p LEFT JOIN preguntas p on d.id_dim...
asked by 29.12.2017 / 07:10
1
answer

Get the number of rows of an SQL query

I have a problem in a query, in this query I have the students enrolled in a section of a specific year and their averages. My goal is how I can get the number of students who pulled at least one course in that year. select N.Descripcion as Ni...
asked by 18.10.2018 / 01:22
1
answer

Limit number of records and sort them

I have two tables one of clients and one of sales where I must select the 30 LATEST records added to the sales table, show the information of the clients that made those transactions and order them upwards with respect to the id of sales...
asked by 18.07.2018 / 01:32
1
answer

How to show a start and end range grouped by states in MySql?

I have a table called documents with three registers id, number, state. What I want to do is get a query with the intervals (min and max) for each record. To be more descriptive if the table is filled, with the following data: | numero...
asked by 21.11.2017 / 06:05
1
answer

mySQL. Nested query on a table

I bring you a question I have about a query that brings me headlong. I have a single table that is inherited from a previous project. In the table among many other data, I have a DNI, a certificate date (FCert) and a renewal date (FRev). In t...
asked by 15.01.2018 / 19:02
1
answer

Query determined by SQL ID

I have a question that I am asking, the fact is that I am very bad at doing it. My table: payments_credit With its columns: credit_pay_id, contract_id, acquisition_date, credit_credit. I try to get the LAST "id_pagos_credito" from my "cont...
asked by 07.04.2018 / 08:21
2
answers

Check MySQL duplicate records (only the first two)

Good morning, I'm new to subqueries, I have a table that registers ip addresses of computers connected to the day, my idea is to list only the first two or a computer corresponding to an ip address I explain (table equipment) my curr...
asked by 23.10.2017 / 06:37
1
answer

Which record is repeated more times SQL

Good afternoon I have three tables in sql I want to know which is the best-selling product EYE I do not need to have the stock as data create table Producto( id_prod int primary key, nombre varchar(15) Precio decimal(2,2) ) create table Vent...
asked by 06.01.2018 / 19:20
1
answer

Use subqueries or joins? Alternatives to left | right join? [duplicate]

Good morning. My Doubt is: Which is better in terms of readability and performance, use subqueries whenever possible or use the "join" format? What is more important, readability or performance? I would understand that many would say that if t...
asked by 15.07.2017 / 00:17
2
answers

Invalid Column Name in a table created with Querys in a Stored Procedure

I want to create an SP with two parameters, Date and Bank, the purpose is that each bank must show (among other data) all the clients in that bank and the amount of cash that will be available in 24.48 and 72 hours. after the Date parameter. The...
asked by 09.10.2017 / 22:22