674,461 questions
0
votes
0
answers
26
views
Access rows in a previous window partition in Snowflake
I'm trying to put together a query where I want to access rows in a previous partition. I'm pretty sure window functions should be used here if I want to do this in one pass, but I'm open to any ...
0
votes
2
answers
135
views
Converting monetary values stored as strings into numeric values
I have a sample data of total column such as [$122,$133,$144,$233.44,$12.45] etc
Total column is in varchar, I am going with CTE approach on calculating the total
First - I remove the Dollar $ sign ...
6
votes
1
answer
142
views
"Aggregate functions are not allowed in recursive common table expression" - but actually, they are?
I have table of structure data in SQL Server. I want to travese the tree and find all nodes with a recursive query.
Additionally, the structure data is versioned. I want to always use the latest ...
-2
votes
0
answers
43
views
Return newly-inserted ID from Access [duplicate]
I found this blog post that explains how to return the ID of a newly-inserted row in generic SQL: https://www.geeksforgeeks.org/sql/how-to-get-the-identity-of-an-inserted-row-in-sql/
Example from the ...
-3
votes
1
answer
87
views
Identifying Used Datapoints within Same Table [closed]
I have a data table cust_rma_track that I use for a Spotfire report, and built 2 visualizations for it. The visualizations are both pulling from cust_rma_track, filtering based off of trans_type. Top ...
1
vote
1
answer
96
views
Pivoting table doesn't return the expected results
I am trying to use pivot, but it's not working the way I expect.
The temptable I want to use input is #GenericTeam:
Versionnumber
Valid_from
Team_name
Attributenumber
Attribute_displayname
...
-4
votes
3
answers
150
views
Why do we need 1=1 in URL SQL injection? [closed]
I was doing the first PortSwigger SQL injection lab, where the goal is to display all “Gifts” products regardless of whether they are released or not.
The official solution is to inject the following ...
1
vote
0
answers
51
views
DBT + Snowflake: how to insert on an autoincrement column?
I am migrating a dag and its queries to a new DB using DBT. The problem is that one of the existing tables has an EVENT_ID column, defined as autoincrement, but when the queries try to insert data, ...
0
votes
2
answers
135
views
Single quote thousand separator
I need to show numbers with a single quote thousand separator in a SQL query, for example:
1'000.00
I tried with something like
FORMAT(ISNULL(value, 0), N'N2')
or
FORMAT(ISNULL(value, 0), '###,###,##...
4
votes
1
answer
120
views
Combine rows and extend timestamp column if same as previous row
I want to be able to combine rows at PersonID level if JobTitleID are the same consecutively, where the timestamp column gets extended if the same.
For example this is the raw data:
I want the output ...
-1
votes
0
answers
74
views
Problems with querying in SQLite(-3), using Greek characters [closed]
We have a database of a DVD club containing several entities some of them in Greek notation. One of them are clients (ΠΕΛΑΤΗΣ):
CREATE TABLE [ΠΕΛΑΤΗΣ]
(
"ID" integer NOT NULL,
...
3
votes
2
answers
232
views
Exception in C# code when trying to call a stored procedure with encrypted param
I have table with an encrypted column UserName:
I also have a stored procedure (in SQL Server) defined as below :
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
ALTER PROCEDURE [dbo].[...
Best practices
1
vote
11
replies
106
views
Avoid using OUTER APPLY in Query
Employee table:
Id
Name
1
John
2
Peter
Attendance table:
Id
EmployeeId
DateTime
1
1
2026-01-10 09:00:00
2
1
2026-01-10 14:00:00
3
1
2026-01-10 15:00:00
This is my SQL query:
SELECT
E.Name, A....
0
votes
2
answers
194
views
Setting OrderNumber of rows in a table
I have a TimeZones table that provides a list of all the time zones in the world with names, offset info, etc. I also have a CountryId column in my table which tells me which country time zones are in ...
0
votes
0
answers
56
views
VECTOR type fails with “Unknown object type” in DiskANN quickstart [migrated]
I ran the DiskANN sample script:
<https://github.com/Azure-Samples/azure-sql-db-vector-search/blob/main/DiskANN/diskann-quickstart-azure-sql.sql>
-- Step 3: Create a vector index on the ...