364 questions
- Bountied 0
- Unanswered
- Frequent
- Score
- Trending
- Week
- Month
- Unanswered (my tags)
1
vote
6
answers
255
views
Select data with self reference in where conditions
I work with a health insurance database.
tab1 contains data regarding drug dispensing. There is about one billion rows per months.
CREATE TABLE tab1
(
id NUMBER, -- patient id
dte DATE, -- ...
2
votes
1
answer
232
views
Extract from nested JSON in SQL
I have a json col in a table along with an id:
id
json_col
abc123
json_text
json value is as below:
[
{
"type": 0,
"isPro": true,
"addOns": [
{
...
1
vote
2
answers
81
views
SQL Different conditions based on where clause
I am interested in if there is an easier way to perform the following query than looping over unions.
What I want to do is have separate where clauses based on different filtering fields. Say I have ...
0
votes
4
answers
157
views
Query outer join fixed values
I would like to query some IDs (fixed values) into a table, like a "outer join" with the mandatory fields should be the fixed values. I have to do the same for SQL Server and MySQL, but with ...
2
votes
1
answer
62
views
rewrite old sql but result of two sql is not the same
I want to rewrite old sql
select * from a, b, c where a.columnA = b.columnB and a.columnC *= c.columnD and a.columnE *= c.columnF
I tried as below
select * from a join b on a.columnA = b.columnB left ...
0
votes
2
answers
129
views
Is there a way to write joining where clauses without AND operator?
Just for curiosity, is there a short/pretty way to write classic SQL where clauses without the AND operator for joining tables?
Classic:
select *
from table1, table2, table3
where table1.fkId = ...
0
votes
2
answers
73
views
How can I join data to my table that isn't available for everyone without losing results?
I have a main table, Table 1, that includes columns for student ID and some other info. There is also Table 2 which includes columns for student ID, survey question, and response.
Essentially, I want ...
0
votes
1
answer
2k
views
Converting VARCHAR to floating decimal in SQL?
I’m trying to convert a "string" column into all float values and can’t seem to get the correct output. The STRING values are all in #.## format (eg. 2.33, 4.25, 3.75, etc.) I have a query that looks ...
0
votes
1
answer
196
views
Databricks change data feed
According to documentation change data feed on Databricks
support both batch queries and streaming queries.
I was wondering if there is anyway to pass the parameters inside the batch queries.
More ...
0
votes
1
answer
640
views
Dremio SQL injection vulnerability
I'd like to query an S3 storage containing parquet files through my Spring Java app with Dremio. These are dynamic queries with user given parameters.
I use Apache Arrow SQl driver and simply run ...
1
vote
4
answers
129
views
Is there a way to delete / update duplicate values in a time sequence?
I have a table that looks like (never mind the database vendor as I need this in ANSI SQL):
create table edge (
parent_id int not null,
child_id int not null,
value float not null,
start ...
1
vote
0
answers
52
views
Is every data type in ANSI SQL sortable?
Can I use an ORDER BY clause with any SQL data type?
For example, will the query
SELECT Column1
FROM TableName
ORDER BY Column1
return results, no matter the data type of Column1, grouping columns ...
0
votes
1
answer
104
views
Comparing various date/time types
Is it defined how a date should be compared to a timestamp with a timezone or a timestamp without a timezone? For example, something like:
SELECT
DATE '2014-01-01' = TIMESTAMP WITH TIME ZONE '2014-...
2
votes
2
answers
387
views
Why is NULL handled differently in aggregate and scalar functions?
Let's take the following two queries:
select greatest(1, val) from unnest([null]) as val
# null
And:
select sum(val) from unnest([1, null]) as val
# 1
My question is why is null handled differently ...
3
votes
1
answer
691
views
SQL Lag on CURRENT_ROW Window Frame
Consider the following SQL window query:
SELECT LAG(no) OVER (ROWS BETWEEN CURRENT ROW AND CURRENT ROW) FROM account;
I'd like to understand what the behaviour should be according to ANSI standard ...