Questions tagged [sql]

Structured Query Language (SQL) is a language for querying databases. Questions should include code examples, table structure, sample data, and a tag for the DBMS implementation (e.g. MySQL, PostgreSQL, Oracle, MS SQL Server, IBM DB2, etc.) being used. If your question relates solely to a specific DBMS (uses specific extensions/features), use that DBMS's tag instead. Answers to questions tagged with SQL should use ISO/IEC standard SQL.

0
votes
0answers
5 views

Postgres “fuzzy” grouping

My application retrieves a lot of IP geolocation data from https://ipgeolocation.io/ and stores it in a database. Main structure is like this: ip isp organization ===...
0
votes
0answers
5 views

SQL Export Wizard has problems with table variables

I had to optimize a query that is being exported daily and i did it by creating some table variables. When i try to export the query now with the Import/Export-Wizard, i get an empty csv-file (it has ...
2
votes
0answers
16 views

Oracle : select words which start by character or associated special character

I'm not very at ease with Oracle. My project uses Java 8, Springboot, JpaRepository and an Oracle DB. I've this query in my repository : @Query("SELECT lex FROM Lexique lex WHERE UPPER(lex.titre) ...
0
votes
2answers
19 views

SQL group by with condition

Imagine i have a table like below: ID Score someOtherColumns 1 1 .... 2 1 ..... 3 4 .... 5 2 .... 6 1 .... where score can have an intger ...
0
votes
1answer
21 views

how to update table with join and case in sql server?

i have problem when update may table UPDATE FGJ SET [base_title]= case when NL.[atypcode_type] = 105 THEN NL.[ATYPCODE] ELSE 0 ...
0
votes
2answers
19 views

Select statement on left hand side of where condition

Would it be a problem if select query is on left hand side of where clause rather than right hand side which we usually use. select * from ABC A where (select ID from XYZ) in (A.ID, A.PID); Is it ...
0
votes
0answers
12 views

sql: keep only frequent pairs, avoid iterative filtering

Let's say there is a dataset of customers and items. For my analysis, I want to keep only customers that have bought at least N different items and only items that have been bought by at least M ...
0
votes
0answers
18 views

Move file to another directory using sql query

I have a file uploaded in: /var/lib/mysql-files/ I want to move this file to: /home/user/public_html using sql query command only I know it is possible with linux commands cd, mv But in my case,...
0
votes
2answers
12 views

Alternatives to using cursor for updating a database based on a subquery

Maybe that title isnt really enlightening but i couldnt come with a less contrived one. Here is my problem: Im working with a table that has data that looks like id cId ver active 1 ...
0
votes
2answers
11 views

Mapping the primary key and foreign key

i have created an employee table as Emp_ID(Primary key), Emp_Name, Address,Designation,Manager_ID(Foreign Key). foreign key is mapped with the primary key. In manager id column i am entering the id ...
0
votes
0answers
10 views

Combine (union) data from multiple sources

Can you help me solve this issue? Create SQL view that will combine (union) data from multiple sources, and rename fields to match SSAS. The assumption is that the data is in the same database. 2.In ...
0
votes
0answers
7 views

MySQL Cursor Store Procedure Condition Showing Duplicate Records

From the share procedure and table duplicate rows are coming in result as in black image shown. As in table only one record matching.
2
votes
1answer
25 views

Arithmetic calculation using previous record for two columns which depends each other in sql

In my table I have to calculate values for different columns. The values can be arrived from current row and previous row. These two column values depends on each other.If I change values of one ...
2
votes
0answers
28 views

Symfony 3 - some difficulties with my doctrine queryBuilder

I started on Symfony and I do not master Doctrine well. I have entities Packages / User / PackagesDDLExterne My Package entity corresponds to packages that the User can download. The ...
0
votes
0answers
13 views

How to fix character encoding in sql query

I have a db2 database where I store names containing special characters. When I try to retrieve them with an internal software, I get proper results. However when I tried to do the same with queries ...
2
votes
4answers
29 views

SQL query to sort data while insert , first numbers then alphabets an last symbols

I am getting trouble to write SQL sort Query, I have table as follows And I want to sort above data as, First should number and then alphabets and last special symbols like following table. First ...
0
votes
0answers
25 views

Datatype compatibility: int vs. nvarchar

I am using below sql statement to read and import data from excel spreadsheet to database table: INSERT INTO [dbo].[TestTable] ([ColumnA], [ColumnB], [ColumnC], [ColumnD]) SELECT A.[AAA], A.[BBB], A.[...
0
votes
0answers
13 views

Using Substring/CharIndex

I've got to extract text from an 'unclean' field in our database. Does anybody know how to extract only: 'daily usage too high' from the below examples? Order: T001.1<br />Rejection Reason: ...
0
votes
0answers
22 views

Error: This driver is not configured for integrated authentication

I am making a Java application that uses an existing sql server, but every time I launch the application I get an error: This driver is not configured for integrated authentication. WARNING: Failed ...
0
votes
0answers
38 views

C#/SqlServer memory leak

I have some problems on my server (windows server 2012r2). Memory is always around 80% of usage and sometime, cpu too and the hosted apps crash randomly (OutOfMemoryException). There is about 110 ...
0
votes
0answers
36 views

Stored procedure doesn't run because of a problem in temp table

I keep getting this error when running my stored procedure: Column '#objects.TableName' is invalid in the select list because it is not contained in either an aggregate function or the GROUP BY ...
-1
votes
0answers
21 views

SQL select the min and max values of the intersecting interval

In MsSQL 2014 I`ve got a table containing intervals of values Col1 Col2 1 3 2 4 7 12 7 15 14 21 I need to get the maximum and minimum values of the intersecting ...
-1
votes
0answers
24 views

How to compare columns with count from different tables?

I have three tables: person, message and hasfriend. Now I need to show every person that has the same amount of friends and sent messages. Person has the info of everyone, most importantly the email....
0
votes
1answer
18 views

oracle sql find overlapping values between two sets

I have two tables ('stock', 'website') have the same structure both has one called 'product_id' I want to find out in what percentage the product_id in the 'website' table also in 'stock' table Did ...
-2
votes
1answer
20 views

Show locations where there is only one item left

I want to display all the locations that have only one item left. Tried using SUM function but it still gives me multiple rows with the same location, 3 article nr that have sum of 1 SELECT location, ...
0
votes
1answer
31 views

SQL Trigger throws error but still inserts

I am working on a trigger that is supposed to block an insert when @verkoperstatus is 0; this does function, but for some reason it also stops the insert when @verkoperstatus is 1. What could be the ...
0
votes
0answers
24 views

Dont know how to solve error : AttributeError: 'str' object has no attribute 'set'

I am trying to fetch the result from the OptionMenu when it is clicked. However I keep getting the error. AttributeError: 'str' object has no attribute 'set' I don't know how to solve this as I ...
1
vote
3answers
21 views

Execute two UPDATEs on complementary data at once in Oracle

I have the following table that I need to update: USER: | ID | ACTIVE | REF_COL | COL_2 | COL_3 | |----|--------|---------|-------|-------| | 1 | 1 | value | value | value | | 2 | 0 | ...
0
votes
1answer
20 views

Fetch email thread from a table with recursive query

I use postgresql I have a table emails: id message_id in_reply_to 1 <me123@gmail.com> null 2 <me345@gmail.com> <me123@gmail.com> 3 ...
0
votes
2answers
25 views

How can i append dataframe from pandas to the oracle table?

I want to append dataframe (pandas) to my table in oracle. But this code deletes all rows in table:( My dataframe and my result become this: 0, 0, 0, ML_TEST, 0, 5 // 0, 0, 0, ML_TEST, 0, 6 ...
0
votes
1answer
27 views

MySQL Query Optimization LEFT JOIN and DISTINCT [duplicate]

I have two table in MySQL : system Id_system Name Type ------------------------------ 1 'System1' 'Type1' 2 'System2' 'Type1' 3 'System3' 'Type1' 4 ...
0
votes
0answers
34 views

Display only total that is greater than 0.00

I want to display only the total which are greater than 0.00 but it didn't display all the numbers that are greater than 0.00. Below is my query: SELECT t2.mall AS mall, t3.company AS compname, t1....
0
votes
2answers
39 views

how to create promises properly in node.js

I'm working currently on a project and I need to make some functions asynchronously. I searched for that, and I found that promises will do the work. Here is my code: var check = `SELECT * FROM ...
0
votes
0answers
11 views

Addressbook: Turn an “at least one list suffices” query to an “all lists need to be present”

I have a SQLite3 database that contains among others these five tables: Addressbook SQL Schema Lists can be assigned to contacts and print jobs. If I want to process a print job (e.g. printing ...
-1
votes
0answers
29 views

How to properly use Export-Csv in this code

I used the code found here http://resolved-error.com/a/17497834/8918324 to make an SQL query that dosen't need to import the libraries for SQL. The goal is having it run on a server and once a week ...
-2
votes
4answers
46 views

How can I compare two string values in SQL?

The problem statement is as mentioned below: When max_pos> 4 and max_neg is >1 then find out the name of rollercoaster where intensity_level is greater than excitement_level. Here, the ...
-1
votes
2answers
40 views

MS SQL : Need to get row wise value from cell for similar rows, Code not working correctly

I have 100s of excel sheets(CSV files) I need to use for the historical load. I am going to load all the CSVs to a stage table using ETL. I am trying to get the row-wise value from the cell for ...
0
votes
0answers
13 views

how to convert rows to columns in postgres using pivot? let me count the ways

query: select count(flag),flag from tablename group by flag; I have the result set from table as following: count | flag --------------- 2 B 45 ZG 3 RET 45 AAR 23 APA i ...
1
vote
2answers
28 views

How to fix slow running SSIS package

I am trying to insert large amount of data from one table from PROD DB to table in Archive DB. Tables are with the identical schema and archive table is with drooped indexes and "Identity insert on". ...
0
votes
1answer
26 views

Two Queries : One to get the most recent and one to get the oldest date?

I think this is an very easy question. I want to get the recent date and the oldest date with a SQL query. The Datefield looks like this: 24.04.2019 If I try to get the recent and oldest date with a ...
0
votes
0answers
38 views

Prevent table joins on same column by mistake

I am using MS SQL Server Management Studio for SQL queries. Sometimes I join two tables on same column, and it takes really long to execute that query. I can't notice this mistake sometimes and it ...
0
votes
1answer
22 views

Finding correct shift based on time in SQL Server stored procedure

I have 8 hrs shifts like this in my table Shift and shiftstart and shiftend datatype as time(7). ShiftNo ShiftName ShiftStart ShiftEnd IsNextDay IsBothNextDay -------------------------------------...
0
votes
0answers
11 views

Publishing database changes with SSDT that include adding columns to existing table to the target database through Project

Publishing database changes with SSDT that include adding columns to the existing table in the target database(which was previously created through SSDT).Instead of creating a new SSDT database. ...
0
votes
2answers
24 views

converting a column result in to multiple row in oracle [duplicate]

I have material_info table in oracle db MATERIAL COUNTRIES ---------------------------- HX345TY US,IN,SG,CN,JP MXT15WO SL,AU,IN,US,AF UIY7890#RT UK,US,IN,SG,PK i want output as below ...
0
votes
0answers
19 views

SQL BigQuery : Select query with time basis

I'm being asked to find the location of user on a database with time basis. For example the location detail between the time 7:00 am to 9am, 11:00am to 2pm and 4:00 pm to 7pm. Big query has timestamp ...
2
votes
0answers
41 views

how to use if condition in mysql with status = 2

create trigger with status with passed with status = 2 and I need to create a tigger after update row second time when del_status = 2 CREATE TRIGGER `exchange_log_update` AFTER UPDATE ON `exchange` ...
2
votes
1answer
32 views

Is there any way to find out specific tag values from XML?

I am setting up alert using extended event in which I am pulling out info in XML format so I got stuck in finding out the values - Object name from this XML. SELECT CAST(data AS XML) AS [result] ...
0
votes
3answers
26 views

SQL get column names in a loop for aggregate function

Lets make it simple: I need counts of all columns from a table. Is it possible to loop through a table names instead of typing each COUNT(column_name) for every single column (if there are >20 columns)...
0
votes
1answer
24 views

EF Core - Using extension method inside Where

I have the following extension method to calculate Product's average rating. public static class Extensions { public static decimal CalculateAverageRating(this ICollection<ProductReview> ...
0
votes
1answer
21 views

Foreign key BIGSERIAL NULL Postgres

I can not insert a record in the POSTGRES database, I want the foreign key to be null. My table: CREATE TABLE sad_avaliado ( id BIGSERIAL NOT NULL, tenant_id INT8 NOT ...

http://mssss.yulina-kosm.ru