674,278 questions
0
votes
0
answers
73
views
Why am I ending up with the wrong number of rows for chained SQLite triggers?
Why am I getting wrong inserts in some chained insert triggers in SQLite (Cloudflare D1)?
Table arrivals has an insert trigger that inserts rows via INSERT OR IGNORE into table places.
Table places ...
-3
votes
5
answers
122
views
Find malls without employees
There is a table called users that looks like this:
mall_id
name
position
1
Max
boss
1
Dan
employee
1
Mike
employee
2
Ben
boss
3
Susan
boss
3
Larry
employee
3
Pat
employee
Each shopping center (mall) ...
Advice
0
votes
2
replies
33
views
How should I manage a large database schema in GBase 8s during application development?
I am currently designing the database for a medical-related software project using GBase 8s. After generating the schema design with the help of an AI tool, the normalized design resulted in around ...
4
votes
2
answers
101
views
Get row index ranges by grouped name, preserving order and gaps
I have a table with a bunch of data that can be simplified down into a non-unique optional names and indexes:
SELECT *
FROM unnest(ARRAY[
NULL, NULL,
'foo', 'foo', 'foo',
NULL, NULL, NULL,
...
0
votes
2
answers
99
views
SQL SUM function not summing [closed]
I am trying to use a subquery to compile the data below into 4 temporary fake but referenceable columns.
events_key
person_name
person_key
event_percentile
event_level
1
A
1
50
composite
2
A
1
75
...
0
votes
0
answers
49
views
Query slow when filtering by timestamp range - is an index required?
I’m experimenting with GridDB and testing some SQL queries on a time-series dataset. I noticed that queries filtering by timestamp range become slow as the dataset grows.
Here is a simplified example.
...
Best practices
0
votes
5
replies
69
views
SQL better prompts to get better data
I need assistance understanding prompts for SQL to get better at it. I know SELECT, WHERE, and FROM are the basics. There are more advanced ways to writing a prompt for SQL to get better data ...
1
vote
3
answers
124
views
How to select elements from list in random order
Character string list contains fixed values
'I','Q','C','K','X','T','S','NE'
known in query creation time. This list should be returned in random order. Tried
select unnest( ARRAY['I','Q','C','K','X'...
0
votes
2
answers
126
views
Compare the sum of two different values group by another column (distinct), and group by of "opposite" value [closed]
I'm trying to write a query to find "matching" data from two different fields within the same table.
For example, a table has a client column, amount charged column and location column. I ...
Advice
1
vote
15
replies
155
views
How should I share, save and combine JavaScript variables across HTML sites?
I am passionate about writing a personality/psychology/dating website. I know how to use variables a bit, but I don't know which is the best way to store them. There are cookies, sessionstorage and ...
Advice
0
votes
6
replies
120
views
SQL INSERT OUTPUT to another table
I have a task required where we are pulling in data originally from another data source and we have the data imported to SQL Server as a flat table called MigratedCustomer. We need to insert the data ...
0
votes
2
answers
117
views
Getting rows when it has multiple rows or only one row in another table based on a column value
I have 2 tables Family:
family_Name | family_id
and Types:
family_fk | type
Request #1: I want to get all family_ids when it has only one type = 'multiple'
Request #2: I want to get all family_ids ...
-5
votes
0
answers
89
views
SQL incorrect output [closed]
I have this data that shows state, number of fatalities in accident, and state population.
enter image description here
What is wrong with this line of SQL, the output is wrong.
enter image ...
-2
votes
0
answers
168
views
Query returning unexpected results when filtering rows in GridDB? [closed]
I am trying to understand why my query is not working correctly.
I am currently experimenting with SQL queries while working with GridDB. I am trying to retrieve specific data from a table, but my ...
Best practices
0
votes
10
replies
84
views
SCD Type 2 implementation using MERGE
I have implemented MERGE statement to capture INSERT and UPDATE records from staging table to Target table. My ask is when I tried to insert already existing records in staging table its simply ...