Questions tagged as 'sql'

1
answer

How to improve this sql code?

I would like to improve this code so I DO NOT REPEAT THE SAME CODE IN THE TWO IFS. I am not in the process of using procedures because I see no need. DECLARE @Ordem VARCHAR (7), @Valor VARCHAR(10) SET @Ordem = 'E' IF @Ordem = 'E' BEGIN SELE...
asked by 30.05.2018 / 22:36
2
answers

What's wrong with this query?

Right, I'm trying to do a select in a database via ajax using jQuery. Here are some excerpts from the code I'm using and more explanations: Ajax function function carregaRegistros(dia, mes, ano) { dia = parseInt(dia); mes = parse...
asked by 01.06.2018 / 20:39
1
answer

Consultation to calculate the number of female and male students

In this query would I use GROUP BY ? This is the template     
asked by 17.05.2018 / 05:15
2
answers

How to use firebird 2.1 ABS in firebird 2.0?

I have a client that already has a system that runs in firebird 2.0 and my system runs in the newer version of firebird, so I had to regress the database and have some functions that 2.0 does not have yet ... Like me could you do ABS (catch abso...
asked by 30.04.2018 / 16:43
1
answer

Problems stopping tables with UNION

I'm trying to get the top 3 from my table and also the last 2 placed, SITE TO RUN SCRIPT This is my current progress that does not work SELECT ('Podium: ' ||TEAM) as name FROM LEAGUE ORDER BY position ASC LIMIT 3; UNION ALL SELECT ('D...
asked by 17.04.2018 / 19:48
1
answer

Mysql procedure error

I'm trying to create a procedure but I'm getting errors, after a few tries, I've been able to solve some problems, but I'm not getting any. Attempting to create generates error > ERROR 1064 (42000): You have an error in your SQL...
asked by 23.05.2018 / 19:20
1
answer

ORDER BY RAND () in 2 columns

Well earlier I posted a problem about deleting 1 select that was solved but now I had another problem. My idea is to create a playlist that prioritizes status 1. Whenever a user posts the video it is inserted with status 1. After the vi...
asked by 04.04.2018 / 02:24
3
answers

For each value of a table show it corresponds, if it does not show zero

What I want to do is this: Show for each row in the sellers table the number of passes sold, but if you have not sold any passes show 0. It has a previous query in the system that makes it look like, but only shows the sellers that have ticke...
asked by 22.03.2018 / 19:06
2
answers

Calculate column date - 6 months from the current date (SQL SERVER)

I have a column in db that is D_EMISSAO and has a date yyyyddmm in it. I have to show the data that is related to column D_EMISSAO if it does not exceed 6 months according to the date D_EMISSAO with the current dat...
asked by 15.03.2018 / 14:00
2
answers

How to do a SELECT while keeping the first column until all records

I would like to do a SELECT that would repeat the first column, but when all the records were over, I would change the data in the first column and repeat all the records again. I'll give you an example to illustrate better, as it's complicat...
asked by 28.02.2018 / 12:50