Questions tagged [sql]
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.
672,944
questions
0
votes
0
answers
5
views
Trying to delete 2 id table using union
I am trying to perform a delete on a table that has 2 id's with the differences of a view that I am using 2 ids on as well. Here is how I am finding the differences in Id's:
Union of differences. Let'...
1
vote
1
answer
17
views
How can I get the count of the number of rows for each date in this table?
I have this table:
City. Date
Paris: 2024-04-28
Lyon : 2024-04-28
Lens : 2024-04-28
Paris: 2024-04-29
Lyon: 2024-04-29
London: 2024-04-30
Swindon:2024-04-30
Paris: 2024-05-01
Metz : 2024-05-...
-1
votes
1
answer
13
views
Any way to add a falsey `ORDER BY`?
I often add in a falsey predicate for convenience in debugging, like this:
SELECT ...
WHERE 1=1
AND/OR predicate1
AND/OR predicate2
...etc
This way I can comment out one or more lines and ...
-1
votes
0
answers
9
views
Running total/Cumulative SUM for Ungrouped Data SQL
Looking to create running totals for ungrouped data in SQL. I'm looking to do a rolling sum of PAID_AMOUNT by INCURREDMONTH and PAIDMONTH. For example,
incurred month = 1/1/2022 and paid month = 1/1/...
-1
votes
0
answers
7
views
Using T-SQL for extracting from JSON
I am trying to extract data from the following json and pivot the data in "rows" to columns.
{
"tables": [
{
"name": "PrimaryResult",
"...
0
votes
1
answer
12
views
SQL: How to select lines when column B equals to certain value and column A is in a certain range
for example , this is a table I have .
If B=1 , then A should between 0 and 10 ,so customer1 is selected , customer4 is not selected.
If B=2 , then A should between 11 and 20 ,so customer3 is selected ...
0
votes
0
answers
10
views
Azure VM: SSRS data driven subscription intermittent error
I have Azure VM database which I use as a source for my DB Source. My SSRS server generates Data Driven report emails out of this db and always have intermittent problems while running my process (...
0
votes
0
answers
16
views
Efficient SQL full data retrieval combining JOINs and WHERE
I have a quite complex data model in my current project's database and I am wondering if there is a better/more efficient way of getting all data, after applying some filters, in a single efficient ...
1
vote
1
answer
35
views
Find records as And in MYSQL
I want find Students id that , must have (professorId = 3 And courseId = 4) And (professorId = 3 And courseId = 2) And (professorId = 5 And courseId = 8).
sometime these parenthesis is one or more ...
0
votes
0
answers
14
views
HIVE query with two filters
if we have a HIVE query where I have applied "where" clause two filters
with period = 24May2024 and
status = 'active'
then will it shuffle all the partitions to filter ** active** result ...
1
vote
1
answer
45
views
SQL Inner join with where clause works fast with one condition, but not when activeFlag is added
I have a query like
select C.customerId, C.firstName, C.LastName, R.IsActive from
Customer as C
Inner join Rider as R ON R.customerId = C.customerid
where R.rideid = 'xyz' and
R.rideareacode = 'abc' ...
-3
votes
0
answers
23
views
Asking for help converting SQL query to EF Core [closed]
I have a working program that uses SQL queries to collect data. I'm working on converting it to EF Core 8.
I found an online convert but the result will not compile in my C# project. Can someone ...
0
votes
2
answers
43
views
Joining tables with different date formats (Literal does not match format string)
I'm trying to join two Oracle tables (basically to pull in a daily rate against the date in another table), but the table I'm pulling the date from has the timestamp in it. I'm seeing a lot of ...
1
vote
1
answer
28
views
Accessing deeply nested fields using DuckDB SQL
I have some deeply nested data from a json file and I'm trying to load it into DuckDB:
"events": [
{
"id": "401638586",
"uid": "s:40~l:41~...
0
votes
0
answers
54
views
Get the no.of records Inserted in last 10 days
In my table I didn't have primary key and forgot to add timestamp column. Now I would need to find the records with date time of insertion in last 10 days. Is there a way to find this? If yes then how?...