Questions tagged as 'sql'

1
answer

Count null and not null fields, grouping by another field

I am building a query that tells me the number of fields that are null and the number of fields that contain some content. Data . This is my table: CREATE TABLE opciones ( ID int(11) NOT NULL, id_pregunta int(50) D...
asked by 22.02.2018 / 00:28
2
answers

SQL query to check free rooms with PreparedStatement in Java

I have this query that I pass it to @raintrooper, in this other query that I did How to check if a room is available? : declare @Vfechaentrada date, @Vfechasalida date declare @reservaciones table ( habitacion int, fechaentrada date, fechasa...
asked by 13.12.2017 / 11:28
2
answers

Transpose a result from one column to another in Postgres

I have a table similar to the following: (only an example to narrow the problem) I need to get to this result in which in the current column for the C concept I have the result of the negative B concept from the previous column. Sup...
asked by 21.12.2017 / 19:32
1
answer

Update data with spaces in sql server

I have a database, with a couple of tables in which I have stored many records that have been brought from another database. My big drawback is that the data has passed with spaces, before the actual data, it seems that sql server will take t...
asked by 11.04.2018 / 23:45
1
answer

Query to database

I'm working with someone else's code, it's a mix of structured programming, POO, MVC. Inside a file task_model.php I have two methods, the first getTareasPendientes applies filters and makes the query with the database to throw the...
asked by 01.08.2017 / 18:23
2
answers

Put a variable as a title in an sql server query

I want you to show me a variable variable in the header. When I do this: declare @dato char(6) declare @sql varchar(800) set @dato='201601' select @sql='select @dato as '+ @dato exec(@sql) I get this error:    Msg 137, Level 15, State...
asked by 14.09.2016 / 17:52
2
answers

Show a field considering 10% of another column using SQL Server

I would like you to help me with this query, I want the costs that are greater than 1000 to show me in another column increased to 10%. At the moment I only have: SELECT * FROM tarifa The result is the following: I hope you can...
asked by 22.03.2017 / 23:00
2
answers

Problems to consult PHP night data

I have the following query to show the average temperature and relative humidity of the last two nights from the current date: SELECT DATE(date) AS Fecha, ROUND(AVG(temperature),2) AS Temperatura, ROUND(AVG(humidity),2)...
asked by 29.09.2016 / 14:25
3
answers

How to group this type of query?

I have problems with formulating the query to resolve the following. I have a table like for example (illustration). I need to group by the trio of columns that appear in yellow and the fourth column of the result of the query would be the rec...
asked by 14.10.2016 / 18:24
2
answers

The input string does not have the correct format. C # SQL

I have an error, as I mention in the good title it turns out that I'm doing a webform in c # and when executing it I get that error Here my code: public void Ordenes(int ID_Orden) { conectar(); consulta = "P_SANCHEZ_ORDEN"; comando...
asked by 01.12.2017 / 09:04