674,290 questions
0
votes
1
answer
26
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
0
answers
36
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
44
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
108
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'...
-1
votes
2
answers
107
views
Compare the sum of two different values group by another column (distinct), and group by of "opposite" value
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
18
replies
113
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
106
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
108
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
87
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
167
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
74
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 ...
Best practices
1
vote
3
replies
76
views
Difference between CONCAT with II and CONCAT with +
What is the difference between CONCAT with II and CONCAT with + in SQL?
Which should be used and when?.
If possible can anyone please explain with example.
Advice
0
votes
4
replies
75
views
Simplifying SQL statement to make it more compact
I am coding some SQL and I needed to return all the countries from the world database where the country name contains "united". The following was my solution:
SELECT name
FROM world
WHERE ...
-1
votes
0
answers
104
views
Efficient way to calculate rolling time-window aggregations in GridDB time-series data? [closed]
I am experimenting with GridDB for an IoT analytics application where sensors continuously send temperature and humidity readings.
Each record contains a timestamp and the measurements. The container ...
2
votes
2
answers
99
views
Obtain list of all attendees with their reg_code in a column headed by year-attended from multiple tables containing multiple years of attendees
So I have 5 years of registration data for show attendees... I want a list of everyone who's ever attended in those 5 years, with their reg-code in a column with the year-attended at the top.
So the ...