Questions tagged as 'sql'

2
answers

How to make a count work by getting only the fields I want?

How can I get a field I want to make COUNT work? select PVN.NFNum, COUNT(distinct CtrlCargaNum) as Qtd from CTRL_CARGA cc INNER JOIN PED_VENDA_NOTA_FISCAL PVN ON cc.EmpCod = PVN.EmpCod where cc.CtrlCargaData between '2018-01-01' and '...
asked by 15.03.2018 / 21:30
3
answers

Bring more than one row in a SubQuery Sql Server

I'm working with 2 queries and would like a way to put the 2 in one, but I'm having trouble. I have the following example: Table T1: CD PF Data Total 1 JSL001 15/03/2018 100 Table T2: ID PF...
asked by 15.03.2018 / 20:58
1
answer

How would I show the person logged at the top of the list

I'm trying to set up a SELECT that displays the person at the top of the list, so I've been showing it at the end of all "SELECT * FROM usuarios ORDER BY id != ? DESC" , I'll give an example, I have a div that shows the names of peo...
asked by 15.03.2018 / 15:36
2
answers

How do I count the number of items in a field repeated?

I have a table with the field CtrlChargeNum that has the log of the number of the load of a truck. I need to make a query that brings the total of that field. Until I got the query, see: SELECT COUNT (*) CtrlCargaNum FROM CTRL_CARGA WHERE Ct...
asked by 15.03.2018 / 20:48
2
answers

how to show the result of a sql in different sections?

How do I make projects belonging to the same department in the same section? $sql = "SELECT d.nome, p.titulo FROM projeto p, departamento d WHERE p.dpto_id=d.id ORDER BY d.nome, p.titulo"; $dpto=null; foreach ($rows as $reg...
asked by 08.05.2018 / 21:22
1
answer

Compare field with multiple values from another field [duplicate]

IwouldliketodoaSELECTbasedonmultiplevaluesofthe[jainscript]fieldandlisttheIDsthatarenotinthe[jainscript]field.I'mtryingwithoutsuccess$sql="SELECT * FROM usuarios WHERE email <> '$email' AND id NOT LIKE jainscrito "; In case if user...
asked by 01.04.2018 / 21:47
1
answer

SQL Server Integration with Android [closed]

I'm having trouble connecting to Sql Server and Android. When I try to communicate, the message "No address associated with hostname." I already did everything I needed, I downloaded Drive jtds, I downloaded sql server 2017, and I could not make...
asked by 09.03.2018 / 18:31
1
answer

Oracle - Cursor

I am studying PL / SQL and testing the use of CURSOR, but I am not able to test an example: SET SERVEROUTPUT ON DECLARE V_NAME VARCHAR2(50); CURSOR CUR_CURSOR IS SELECT FIRST_NAME FROM EMPLOYEES; TEMP CUR_CURSOR%ROWTYPE; BEGIN IF N...
asked by 29.03.2018 / 16:31
1
answer

SELECT TOP that brings all the results, something like TOP all, exists in SQL Server?

During my studies, I tried to sort the records and put the ones that are NULL at the end, I did the following: SELECT tbl1.firstname, tbl1.mgrid FROM ( SELECT TOP 100 firstname, mgrid FROM HR.Employees...
asked by 29.03.2018 / 16:06
1
answer

Script Generate Excel SQL SERVER

I have a select and I need to generate an excel through it. However there are some observations. I would like this script to run every day at a certain time, 23:55 for example, as it is to get the request data open that day. Another question is...
asked by 07.03.2018 / 18:06