query

Convert varchar to date in SQL

Has how to convert dates in varchar to date. I am having difficulty performing searches between dates, due to this discrepa ... and dt_item between '15/05/2017' and '31/05/2017'; The result of my search returns me values of dates before my range.

Difference between hours without taking into account the date

Good Night, I have the following code: WITH CONSULTA AS ( SELECT V.CHAPA, V.DATA, MAX(V.BATIDA) AS MAXBATID ... 07:31 08:31 09:31 10:31 11:31 12:31 12:56 That is, without comparing the dates, would this be possible ? SQL SERVER 2008

SQL - how to make multiple INSERTs in a table with the result of a SELECT * from another table in a query

Hello, I would like to know how to make multiple INSERTs in a table with the result of a SELECT of all the Ids of another tab ... m the other table that are not in the first one, what I want is to type a repeat structure that will execute INSERTs n times.

Difficulty mounting SQL query with UNION with SUM

I have 2 tables that stores different sales type, and I need to add everything to get the amount to generate the charge, but ... iente I am having the following error: Error: syntax error in or near " group" LINE 30: group by CL. id_cadastro_cliente

How to reduce the search time in a table with more than 200 thousand records?

I'm trying problems for listing and searching data in table with more than 200 thousand records. I read in searches, that fo ... JOINS to display the results on the screens. Now I need to think of a way to replace the JOINS and display the same results.

Limit and Offset for web paging in SQL Server

I am working with PHP and have about 8000 records currently in DB. As it is for a web page, I need to do a pagination to mak ... usuario.idCliente from usuario where usuario.login = 'julio') order by dataHora desc GIST How to proceed in this case?

How to join 2 tables without repeating data?

I have 2 tables, one call SR7010 and another call SR3010. The primary key of the two is the field R7_MAT and R3_MAT. The que ... appens when I do a search in the table SR3010 by the field R3_MAT = 997. It also returns 3 records, so I'm finding it weird.

Dateadd working hours-SQL Server

Guys, I have a doubt. In the query below, in the tarvencimento field, it is counting the hours normally, however, I want it t ... CASE WHEN @CONTMINUTOS < 10 THEN CONCAT('0',CAST(@CONTMINUTOS AS VARCHAR)) ELSE CAST(@CONTMINUTOS AS VARCHAR(5))END) END

Why does GROUP BY not work with MySQL in this case?

I'm using MySQL language and I'm trying to Group A table of professions with GROUP BY through the query below. SELECT name, ... d is in list form. But when making a brief consultation of the professions, he returns this to me: Why does this happen?

How to fetch data from one table using reference from others?

I will exemplify with one simple thing... I have a 'products' table that has in the columns, id, product name, value. I have ... Roupa Good... if or user already bought... I want it not to appear on the list anymore. how do I use this with select?

Which is more efficient, perform multiple queries or use JOIN?

I have a table X that has my user's data, and I need to return to the client the data related to that user in the table Y and ... g JOIN or: SELECT attr1, attr2 FROM Y WHERE X_id = id SELECT attr1, attr2 FROM Z WHERE X_id = id Which is more efficient?

SQLite error: foreign key mismatch (FK incompeteis) when trying to make an INSERT

I am trying to create a associative entity (N: N)in SQLite like this: [Pet - - - - - - Vaccine ] And, here is code ... UES ('23/05/2018', 0, 1, 1); What can be wrong? Note: I have data in Tables Pet and vaccine , they are not empty of data

How to delete all duplicates except one?

I have a table that has duplicate records. They should not be duplicated. Some records doubled two, five, and even thirty t ... cates if the status is 0, but I want to leave one. How to make a query that deletes duplicates, but always leaving a record?

Calculation of the mean between Selects SQL

Good Afternoon Please help me Error in syntax Msg 102, Level 15, State 1, Line 2087 Incorrect syntax near 'TAB'. ... e one I need to insert and is repeating. The column of the tariff average is the correct result (calculate average by excel)

"Translate" query from MySQL to SQL Server 2012

Which SQL Server 2012 query matches the next MySQL query? REPLACE INTO schedule SET jobname = "sqldump" , last_exec_date = NOW()

Smart query with MySQL

I'm trying to make a more "smart" query in my DB, my doubt is how? I have a query : SELECT * from publicacao where titulo ... rmácia Pharmácia Pharmacia Farmacia When searching by pharmacy, the 4 lines should be returned. Is it possible to do this?

Converting an nvarchar data type to a datetime data type resulted in a value out of range

Line of code INSERT [dbo].[Shop_Goods] ([TemplateID], [Name], [Remark], [CategoryID], [Description], [Attack], [Defence], [ ... from the break. Wanted to know why the error, I'm running a query of almost 10 thousand lines and several gave this error.

Backdated in mysql

Good morning everyone! how do I do, in a query in mysql catch generate dynamically the date referring to 3 months ago?

SQL search for more than one type of property, city and neighborhood does not work properly

I got a ready template with some problems in plugins and queries. Of the 6 select fields to search for properties, 3 of them ... t;/div><!-- #listImovel --> <div class="clearboth"></div> </div><!-- #pageListagem -->

php Echo html tag as text

I have a query in php / oracle that when showing the result in the browser, hides a tag "" while in oracle sql developer pres ... )', 'Closed', 'Rejected', 'Cancelled', 'On_Retest') AND bg.BG_USER_TEMPLATE_09 IN ('GA - CSC', 'GA-OI', 'GA - OI') UNION ALL