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.
582,814
questions
-2
votes
0answers
9 views
Date change to previous month
I have date 11/23/2020
I want output as 02/22/2021 because today date is 16th March 2021, if today date is 16th April 2021 then I want result as 03/22/2021 for date 11/23/2020
tried using Datetime ...
0
votes
0answers
11 views
How to get child nodes and flatten the table in spark sql
I have a table with 2 columns in databricks and trying to get all the child nodes of a parent in spark sql.
Parent Child
A
A B
B C
B D
D E
Output 1 :
Parent Child All_Node
...
0
votes
0answers
14 views
Writing a SQL Server query to unpack XML formatted data into individual colums
I have a table named EventData.
This table has a column of XML type, the column name is XmlData.
XmlData contains data in the following format:
<Data>
<Head>
<Site>Site1</...
0
votes
1answer
21 views
Canonical way to store reciprocal data sql
I got a lot of instances of the same Class. Now these objects can be linked and this link can have a weight. Like in an undirected graph. Now I want to store the relationship between each two objects ...
0
votes
1answer
17 views
SQL How to find specific value that is not in another result
tldr;
I want to filter out result by checking if current result DOES NOT EXIST in another result
So currently I have these 2 queries
SELECT
dosen.nama
FROM
dosen AS dosen
INNER JOIN role as ...
0
votes
1answer
12 views
Maximo/Oracle SQL statement returning unwanted data from joined tables
Pretty sure it's a simple fix, but I'm lost. Trying to pull data from joined tables where there's a checkbox = 1 (gditwocertflag). I only want to see the specific row that's checked. But I'm ...
0
votes
1answer
21 views
Why does my UPDATE query take so long when my SELECT query doesn't?
I am trying to do the following: let's say I have the following SELECT query (please excuse the german column names):
SELECT a1.aktivit?ts_id, a1.herkunft_kontakt, a1.aktionsart, a1.aktionstyp, a2....
0
votes
0answers
14 views
Error While Trying to collect the result of a SQL query in SPARK (Scala)
I'm following a basic tutorial in Spark, in which we're asked to import a .csv file into a database, performing a query and collecting the results of that query.
To do so, we first create a Persona ...
0
votes
0answers
6 views
Running SQL scripts on Google Cloud
I've created a trigger script for a SQL Server and I want to run it from the file it's in, but I can't find any resources from Google on how that is actually done. Has anyone tried doing this before?
0
votes
0answers
18 views
Confused quetions for Data Query Languages SQL
hi everyone I would to ask about queryLanguage, I have got question like this "You are writing a SQL query to analyze data about recent trampoline sales. The Store_sales table describes the ...
0
votes
1answer
26 views
what does %(parameter)s means here
I have a code snippet like this. I am confused about the use of %()s.
If it is used to format parameters,
shouldn't we use %(threshold)d for threshold since it's a number?
# Join with the courses ...
0
votes
0answers
20 views
do we have conditional insert or update in db2 like we have if else in sql?
I want to check if we already have a record exist in table , if yes then run update query else insert query should be executed in db2 databse.
0
votes
0answers
20 views
Aggregate multiple rows into one
I have a table with ~3 million rows. Many looks like this (sometimes up to a 100 per customerid):
Customerid
Town
E-Mail
Address
123
null
sample@gmx.de
Fakestreet 123
123
New York
null
null
123
...
0
votes
1answer
11 views
Best type for ID column in Activity Log table
I need to choose a type for ID column in Activity Log table which would look like this:
ID
Type
UserID
User Logged in
UUID1
Something happened
UUID2
Any thoughts or recommendations?
-1
votes
0answers
40 views
SQL Server column increment by 100.000+ instead of 1
We use SQL Server 2019 and realized that Id column of some tables are increased by more than 100.000 instead of one by one. According to the some report e.g. Identity increment is jumping in SQL ...