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.
633,753
questions
0
votes
0
answers
3
views
Make a multiple INSERT based on checkboxes and using the id
So I was trying to make a multiple insert based on checkboxes, I have this table Table photo. This is my input: <td><input type="checkbox" name="checkbox[<?php echo $...
0
votes
0
answers
4
views
Sorting columns in a sql view results in different performance
I have a problem with sorting results in a sql view, when I sort by one of the columns which is nvarchar it sorts fine and quick when I sort by other column which is also coming from the same table as ...
0
votes
0
answers
7
views
SQL Query Running Slow I need help optimizing it to improve performance
I have this SQL Query, it is running really slow, I need to improve the performance of it, any advise would be helpful.
SQL Query BELOW:
SELECT DISTINCT(b.projid),a.Id,a.Company,a.ProjectType, a....
0
votes
0
answers
4
views
Postgres Average Filter based on date
I am having a postgres table which is updated by a cron for every hour. I need average of that volume based on 1 day, 5 day, 10 day. when i average it like this
select avg(volume), id from price_table ...
0
votes
0
answers
5
views
How to link a server to an ODBC Dsn requiring a password, in SQL Server
I have an ODBC driver that I would like to use as a linked server in SQL Server, the problem is it requires a password. I can connect to the DSN in a c# application like this:
OdbcConnection conn = ...
0
votes
1
answer
8
views
How can I count the total no of row which is not containing some value in array field? It include null values as well
| names |
| -----------------------------------|
| null |
| null |
| [{name:'test'},{name:'test1'}] |
| ...
0
votes
0
answers
7
views
Count Distinct IDs in a date range given a start and end time
I have a BigQuery table like this
id
start_date
end_date
location
type
1
2022-01-01
2022-01-01
MO
mobile
1
2022-01-01
2022-01-02
MO
mobile
2
2022-01-02
2022-01-03
AZ
laptop
3
2022-01-03
2022-01-...
-5
votes
0
answers
23
views
Alternative to UNION ALL
I want to get the below result without using UNION ALL as it is impacting the performance of the select query.
I have 2 tables table1 and table2, I want to concatenate the values from the first ...
0
votes
1
answer
17
views
How can I merge this query so that it returns only one column?
I have the following table:
Player Name Nationality
Romelu Lukaku Beligian
Christian Pulisic American
Kai Havertz German
Masoun Mount British
Reece James British
Edouard Mendy French
N'Golo ...
0
votes
0
answers
3
views
Toad Data Point Cross Connection Query / Unrecognized date time format
I am trying to filer this cross connection query by the date/time but keep getting a formatting error (AND BD.InspectDate >= '6/13/2022 12:00:00 AM'). I tried to convert to Date (AND convert(date, ...
0
votes
0
answers
13
views
MERGE statement - Don't update OR insert when a condition is met between source and target
MERGE StudentTable as target
USING MemberTable as source
ON target.StudentGUID = source.MemberGUID
WHEN MATCHED
THEN UPDATE
SET target.CourseId = source.CourseId,
target.HomeCityId = ...
0
votes
0
answers
5
views
MS SQL Server Data Anonymise
I have a below requirement
We are going to restore production database into UAT for testing few usecases. We should anonymise required data's (Ex: SSN, Credit Card etc) from all types of users ( ...
0
votes
1
answer
24
views
SQL Case Statement: Set the default value for an Case
this time I need an explanation for SQL. I have seen on the internet now nothing special and maybe I have a thinking error.
I have a case statement and now I want to " filter " it in ...
0
votes
1
answer
10
views
Measuring the averaged elapsed time for SQL code running in google BigQuery
As BigQuery is a shared resource, it is possible that one gets different values running the same code on BigQuery. OK one option that I always use is to turn off caching in Query Settings, Cache ...
0
votes
1
answer
16
views
PostgreSQL: Select latest entries only when values differ in a column
Imagine the data:
id audit_id val updated_at
1 11 43 October 09, 2021, 07:55 AM
1 12 34 October 11, 2021, 11:03 PM
1 13 88 January 23, 2022, 01:...