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.

-4
votes
0answers
13 views

changes in the conection string [on hold]

I whant change in my progrem the data base source,where do i need to change it in my program?
0
votes
0answers
3 views

How do I select offset documents in Kentico?

I'm trying to list several child pages based on most recent date, however for some sections I want the top 3 documents and some areas the rest of the articles from the same folder. My current SQL ...
0
votes
3answers
19 views

Select rows with the same foreign key but another column has a set of values

I have designed a database that stores data in a format like this where both columns are foreign keys leading to different tables. This is a simplified version. RNA_id | Experiment_id | 1 | ...
0
votes
2answers
28 views

SQL Query with MAX and CASE WHEN

I have the below sql query and its output is as shown below: select stds.classID as classID , stds.clsLimit as clsLimit , max(stds.id)as maxStdsID from class cls left outer join students stds on ...
-1
votes
0answers
10 views

I have a question How can I create a file through SQLplus and save it to intellij to connect to the database?

I have a question How can I create a file through SQLplus and save it to intellij to connect to the database ?!
0
votes
1answer
13 views

Manage SQL query multidimensional array output as stdClass Object

I using an MVC framework with controllers and routes. I am trying to define some PHP variables from the database. +---------+---------+-------------+---------------+ | meta_id | post_id | meta_key ...
0
votes
0answers
12 views

Converting SQL Server Table in form of DataFrame into String so I can parse using Spacy.load

I am trying to convert a table on an SQL server which comes out as a DataFrame into strings which I can parse through using the nlp = spacy.load('en_core_web_sm') notation. However, I am getting ...
0
votes
2answers
14 views

how to pick the column with the highest value

I have a table with different possibilities of marital status (columns), how do I pick up the one with the highest value and keep the column name? For example, below is my original data set: data ...
0
votes
0answers
26 views

how to find the bottle neck in a bulk insert

I'm running a BULK INSERT in SQL Server for about 400,000, its taking between between thirty seconds and a couple minutes. The table I'm inserting in has PKs but no other index. How can I test what ...
0
votes
0answers
22 views

Conditionally finding proper date in SQL based on positive or negative row value?

I am attempting to find which "replenishment" (a positive transaction quantity) can be matched to a "requirement" (a negative transaction quantity). The basic logic would be: For a given requirement, ...
1
vote
0answers
17 views

Operand type clash: date is incompatible with int?

Can someone help me out here, I have the following TSQL that is throwing errors (it is part of a table view). SELECT MAX([WEEK]) FROM MyTable WHERE [Year] = DATEPART(YYYY, GETDATE()) This is part of ...
0
votes
3answers
26 views

SQL - Calculating third column from previous two

I have just started SQL and have some difficulties in terms of thinking in this language. I have now a task where I need to create a new column in a table with values from previous columns. This ...
1
vote
2answers
19 views

SQL view of union with parameter on each subclause

How can I create a VIEW which produces the same result as the following SQL at bottom. The VIEW needs to be usable by anyone in this manner: SELECT * FROM my_view WHERE merch_id = 'some_value'; The ...
-3
votes
1answer
30 views

Delete rows to keep only top values in a sql table

I am trying to have some product recommendations in my website. I have this table that i have generated but need to keep a limited amount of entries. The table consists of these columns (filling with ...
0
votes
1answer
17 views

Comparing start dates and end dates using SQL in SAS

I'm trying to compare start dates and end dates to make sure that start dates aren't later than end dates. Tried posting onto sas community website, but too many post restrictions errors table: ...
0
votes
0answers
15 views

SQL Pull rows where there is a 25% decrease in one column within 72 hours (another column has dates)

# patient_ID Performed_date Admit_date Discharge_date Result rn 1 1 8/26/18 10:20 AM 8/25/2018 8/30/2018 30 1 2 1 8/27/18 11:40 AM 8/25/2018 8/30/2018 30 2 3 ...
0
votes
1answer
22 views

using update in trigger

I have trigger on delete I want to delete policeman but when I delete him all other policeman that he is their boss will have null in their boss field so I used this code create or replace trigger ...
0
votes
0answers
27 views

How to get this output in spark sql?

How do I get this output of listing all the movies for each year in spark.sql? Ouput: (1988,{(Rain Man),(Die Hard)}) (1990,{(The Godfather: Part III),(Die Hard 2),(The Silence of the Lambs),(King of ...
0
votes
0answers
17 views

Laravel Query. Obtain in Eloquent only totals > 0

I have this query: public static function totalByAgent(int $agentId) { return PropertyListing::select(DB::raw('SUM(property_listing.rental) ...
-1
votes
0answers
26 views

Query returns no data even though it exists?

Programming Languages: SQL, PHP Classes: Page, Filter, Table (All written in PHP to render formated pages, Pure-CSS Filters, and standard html tables) Outside Library: PDO: PHP Data Objects https://...
0
votes
1answer
26 views

I have a problem with the grouping for this query

I have a problem grouping a 4 join table. Due to new goverment regulations that every private service vehicle must be periodically serviced and have proper training, RideWaiki is required to report ...
-5
votes
0answers
29 views

How to cross split 2 string column in single query [on hold]

Want some solution where i can apply 2 cross apply split_string and select the output as shown in output picture or any solution by which i can achive my requirment INPUT values coming ...
0
votes
0answers
21 views

How can i transpose sql oracle table depending on pivot table column types?

I have table (phone_item) that has structure key (varchar), value (varchar), description (varchar). I need to transpose this table into another table (phone), where column_name=key and row values need ...
0
votes
0answers
11 views

Narrow page results/output based on equal fields in 2 tables

I have three tables where I want to narrow the displayed results of table 2 (policytype), based on a matching Niche in table 1 (broker) it displays a list of Policies (policyname) for a specific ...
0
votes
0answers
17 views

Does Django support named parameters when executing custom SQL?

I want to execute some custom SQL in Django using named parameters (aka pyformat), e.g. .. WHERE name=%(name)s. I've noticed that the docs only mention using %s placeholders, and not named parameters. ...
0
votes
1answer
38 views

How alter a procedure dinamically in SQL-Server? [duplicate]

I have a testing DB that restores himself everyday. I want to alter a procedure for everyday in the morning. Right now, I'm trying it using this code: DECLARE @SSQL1 NVARCHAR(4000), @SSQL2 NVARCHAR(...
0
votes
1answer
10 views

SQL Group By min value usable as a variable? [duplicate]

I have the following table ComponentsB: CID Name PPP ProcessingCharge LName Typ 1 RadXL 10 5 EisenAG Rad 2 RadXL 15 0 LederGmbH Rad 3 RadL 10 2 LederGmbH Rad 4 ...
0
votes
2answers
43 views

Why is using an alias in the having clause working?

I am using a group by and having clause in my query and the having seems to be working fine using an alias. No matter what value I put in, or operator (<, >) it returns the correct result. ...
0
votes
2answers
34 views

Remove trailing zeros along with a case statement

I've been trying to remove the trailing zeros from a column of a table. When I use a case statement (to remove the zeros when a flag is turned on, and to keep them when a flag is turned off) it doesn'...
0
votes
1answer
23 views

Getting repeats of output, possibly doing a join wrong?

I'm having an issue where I'm getting some incorrect values in my output. I am binding the below highlighted table column with the circled column down the bottom. The service_id on the highlighted ...
0
votes
3answers
32 views

How to get the average score of a department using sql

I want to get the average score of all department in my database, I have a query that get the average score of just one department, is there a way I can get the name of the department and their ...
0
votes
1answer
14 views

SQL Multiple subquery issue

Currently struggling with a second subquery (t3) which is giving me a syntax error. The query works fine if t3 is excluded. SELECT switch(LEFT(t1.[treatment],1)='C',"Complaint",LEFT(t1.[treatment],1)=...
0
votes
1answer
15 views

Running SQL-like queries on .net assembly metadata

I know the metadata of .net assemblies is stored in a tabular way, as described in ECMA-335. Has anyone developed a way to query this data using an SQL like language (or any query language!)? The ...
0
votes
2answers
20 views

I receive an error using an integer as a parameter

/* I'm passing an integer as a parameter in a SQL stored procedure but receiving an error despite declaring the input value. The intention is to use the value passed to the parameter in dynamic SQL ...
1
vote
3answers
29 views

Query data between the same date

Is it possible to do something like this? select * from table where Date BETWEEN '2019-05-29' AND '2019-05-29'
2
votes
1answer
32 views

How to filter out distinct pairs in a table?

Followup to a previous question: How to remove duplicates so that only pairs exist in a table? So I'm trying to filter out distinct IN/OUTs for each ticket_uuid in a ticket_events table For example, ...
0
votes
1answer
16 views

How to retrive json data from sql table column into as a separate table

I have customer table with columns names "orderid", "body", "time", Below is the JSON data in side "body" column: {"PersonTitle":"Mr","FirstName":"david","LastName":"ford","PhoneNumber":""}. How do ...
0
votes
0answers
28 views

I want to write a 75000x10000 matrix with float values effectively into a database

thanks for hearing me out. I have a dataset that is a matrix of shape 75000x10000 filled with float values. Think of it like heatmap/correlation matrix. I want to store this in a SQLite database (...
-1
votes
0answers
22 views

Shared data with Sql Azure

We have some crucial data, which is imported via Azure Functions from a external data provider and is now integrated in one database and codebase. But now we are starting a new codebase ( different ...
0
votes
3answers
49 views

Select column using different WHERE clause from a different table

Like many questions that have been asked on here, I need to be able to select the same column twice, using 2 different WHERE clauses. Unfortunately, there is a problem as I am also trying to fix ...
0
votes
0answers
9 views

Removing HTML tags in Oracle SQL developer

I have a data set of emails in html format. I'm trying to extract the email content only, using this code: CREATE TABLE htmls (value) AS SELECT mail_body FROM TBL_MAILS; SELECT value, ...
0
votes
3answers
28 views

Split STRING into OR in Access SQL Query

I'll start by saying I understand very little of SQL which is why I haven't tried doing this myself. What I'm looking to achieve is as follows. I have a string with several unique IDs and I'm trying ...
1
vote
1answer
48 views

T SQL Select tables based on values from another Select

I have the below select that retrieves all tables that begin with 'ABC_': SELECT * FROM information_schema.tables WHERE table_name LIKE 'ABC_%' All of the 'ABC_' tables contain a field called 'SKU'....
0
votes
2answers
20 views

Replace Database field based on 2 different Table Conditions

I need to update the table based on email matching condition and need to know SQL query that can solve this problem. I have 2 tables "old_data" and "new_data" Old_data contains around 60,000 records ...
0
votes
0answers
6 views

Select donut chart segment in order to drill down to a stacked chart

For some background, I am learning to use Oracle Apex and at the moment I have a page with two drop-down lists. The first drop-down list displays available databases. The second drop-down list is ...
2
votes
1answer
17 views

Remote delete inconsistently hits resource limit / timeout

My SQL Agent job runs every morning at 4 AM. It has 10 steps. The last few weeks, it has been failing a couple times a week on Step 3 with this error. The OLE DB provider "SQLNCLI11" for linked ...
0
votes
2answers
18 views

Drop row that has different value from its next row in PostgreSQL

I have a table that look like this: type date amount ----------------------------- A 17/06/2019 5 A 18/06/2019 8 A 19/06/2019 10 B 17/06/2019 1 ...
0
votes
1answer
24 views

null result for average number of days by month

select a.clientid, a.CaseType, b.EnrollmentStartDate, a.EligibilityStartDate, datediff(day, a.EligibilityStartDate, b.EnrollmentStartDate) as date_diff INTO ##temptable1 FROM dbo.Client a, ...
1
vote
1answer
20 views

Select from array in postgresql to get all possible results

im using postgresql 11.2 on a docker container and im trying to get data on this column that containes arrays "event_type" : event_type ----------------- {ERROR} {INFO} {ERROR,VERBOSE} {ERROR,...
0
votes
0answers
17 views

I need make a pool.query with 2 conditions

I need make a pool.query with 2 conditions inside a route.I use for my database mysql. I'm working with node.js The route router.get('/category/:category', isLoggedIn, async (req, res) => { ...