Questions tagged as 'sql'

1
answer

How not to repeat data in this query

I made this query, which will compose a view. SELECT DISTINCT US.EMPLOYEESTATUS ,US.EMPLOYEEID ,US.EMPLOYEEFIRSTNAME + ' ' + US.EMPLOYEEMIDDLENAME + ' ' + US.EMPLOYEELASTNAME AS FULLNAME ,US.GRADE ,SO.SOLICITATIONID ,...
asked by 13.09.2018 / 13:39
2
answers

Table values being truncated

I made code in the declaration part of the real number that word balance that it will get a number with 6 digits and 2 two decimal places after the comma, but all the values that I enter are truncated, how to solve? > create database uri defaul...
asked by 27.04.2018 / 20:49
2
answers

Problem with CASE WHEN SQL-SERVER

SELECT CASE WHEN VALOR > 0 THEN VALOR ELSE "Não tem" END AS NOMECOLUNA FROM BLABLABLA I'm having an error where it's not possible to convert "does not have" to int. The issue is that I wanted it to return written that it does not have wh...
asked by 27.04.2018 / 14:17
1
answer

Array split with array_push for multiple INSERT in SQL

I have a foreach looping in a file's data, this loop generates some values that are entered in array with array_push , precise break those values entered in this array to generate multiple INSERT INTO because...
asked by 01.05.2018 / 04:10
2
answers

Sum on a Pivot Table

I'm learning how to use tables with PIVOT in Sql-Server. I have a table with the item name, the vendor name, and the customer id. Item | Customer | ID Rep Pen Set | 1001 | Richard Binder | 25092 | Nick Pen Set | 5149...
asked by 30.04.2018 / 06:57
1
answer

Browse the best-selling product

I'm having difficulty joining two tables and using some aggregate function, I've tried it like this: SELECT nome FROM produto INNER JOIN vendaproduto SUM(quantidade) ON produto.idproduto = vendaproduto.idproduto But it is giving error ......
asked by 12.06.2018 / 02:42
1
answer

Querying database using ORDER BY kills my search

My code displays a list of people and a search field at the top. everything works fine, including searching. but I need people to appear randomly. The problem is that when I use the ORDER BY rand () (or any other ORDER BY) my search stops workin...
asked by 09.06.2018 / 06:11
1
answer

How to format the numbers directly through SQL

Gentlemen, my numbers are coming out unformatted when I make the select directly in the bank, they are coming out as follows: REALIZADO META 61274436,2090003 80000000,00 How can I make them readable for anyone to interpret?...
asked by 30.07.2018 / 20:50
1
answer

How to create a single index in a table so that it only has a record with a specific value in SQLServer

Hello, I am creating a data structure in SQLServer and I have the following situation: I have a list of contact types (people, public, commercial, etc ...) This list can be changed by the user, but it can only have 1 element as default....
asked by 30.07.2018 / 16:18
1
answer

Concatenating values directly in the query is problematic?

These days, a guy told me: "Avoid forming SQLs by concatenating strings. Doing this is asking for security issues with SQL injection, and for that reason it's considered a bad programming practice." > What about merge variables into a String t...
asked by 10.02.2018 / 20:44