Questions tagged as 'sql'

1
answer

Doubt in the method of using Distinct and Count together!

I have a table requests as the example below: Id | Cliente | Status 1 | XPTO | Proposta 2 | ABCD | Proposta 3 | XPTO | Venceu 4 | XPTO | Perdeu And I want to present a result like this: Cliente | Status | Qtd XPTO...
asked by 04.08.2016 / 19:24
1
answer

Group Duplicate Records in a Single Line

I'm having a problem with a query, in which I need to transform rows into columns. In the case I thought about using the pivot function, but it did not work very well, since mysql does not give me such a function. But the tables are as follows...
asked by 01.11.2016 / 00:56
1
answer

Display the Average in an SQL query

I want to perform a search on a query so far I have only been able to display the total value of the logs.  the idea is to show the average spending. Then it would be the (total / quantity) but I could not mount the logic: what I have so...
asked by 25.11.2015 / 13:52
1
answer

Error DataBase Locked Sqlite / Java

I have the following problem: in an insert that I am trying to perform, I do not know if it is an error in the database or something in the programming in java, however every time I try to perform an insert of the client table I get the error: p...
asked by 24.12.2016 / 18:24
1
answer

QUERY - Can anyone help me build this query?

I have these 3 tables below: "users", "friends" and "posts". I want to get all my friends who are in the friends table and display their posts, taking their name and their image (which are in the users table). Imagine a news feed, where I...
asked by 03.01.2017 / 13:11
1
answer

Remove Duplicate Space in the Middle of the String

Hello, I need to remove duplicate spaces in a string and leave only 1, identical to the Excel sort function. How to do this in sql?     
asked by 11.04.2016 / 16:20
1
answer

Execution order of migrations

Hello On my first job, I worked using code-first with the Entity Framework 4. At this time, I saw a limitation on it: the generated migrations only ran in order. For example, if two people are working with persistence in my branch, generated...
asked by 21.03.2016 / 22:40
4
answers

Prioritize word in SQL query - MsSQL

I have the following task: Make a query where I have to give preference to the last word as a parameter. I search in two fields with a OR , but I need to prioritize the query by the first field. For example: if I search for "% phy...
asked by 18.02.2014 / 14:16
2
answers

verify that multiple fields are created in the database

A further 7 columns have been added to a table, but you must first check if this column is in the database, otherwise you should not run the column creation script. Is it possible, in a single condition, to check whether the columns have alre...
asked by 25.08.2015 / 15:57
1
answer

How to get the value before MAX in SQL?

How can I get the value prior to MAX in SQL? I have tried MAX -1 but it did not work, because the column values I want to select the value before MAX are not in ascending order.     
asked by 04.08.2015 / 18:17