All Questions
674,237 questions
Advice
0 votes
7 replies
21 views
Getting percent but total percent is sometimes 99 or 101
I have this query my goal is to get percent NVL(ROUND(100 * NVL(activeCount, 0) / NULLIF((NVL(activeCount, 0) + NVL(blockCount, 0) + NVL(closeCount, 0) + NVL(draftCount, 0)), 0), 0), 0) AS ...
-1 votes
0 answers
28 views
Why does COUNT(*) return a different result than COUNT(column_name) in a LEFT JOIN query? [duplicate]
I am trying to count how many orders each customer has. I noticed that COUNT(*) and COUNT(o.order_id) return different results and I don’t fully understand why. Here is a simplified example: CREATE ...
-1 votes
1 answer
66 views
Why does LEFT JOIN return fewer rows when I add a condition on the joined table in WHERE clause? [duplicate]
I am trying to list all customers, and show their orders if they have any. If a customer doesn't have any orders, I still want to see the customer in the result. CREATE TABLE customers ( ...
-7 votes
0 answers
87 views
Integration of cursor project code to Supabase [closed]
[enter image description here][1] I have been trying to connect my Supabase to my cursor project and for that I ran the SQL code shown below in the SQL editor of Supabase. My code from cursor: -- ...
3 votes
2 answers
147 views
Return data between certain Hour values
I am trying to determine if it's possible to query for data between two defined HOUR values from a DateTime value, instead of writing out each DateTime iteration. This need is to find matching values ...
Best practices
1 vote
4 replies
95 views
Passing columns as function arguments (paired)
I'm calling a function with "paired" arguments: WITH ts AS ( SELECT t.c1, t.c2 FROM t ) -- `ORDER BY` to guarantee the same order SELECT f( a => ARRAY( SELECT ts.c1 FROM ts ...
0 votes
1 answer
118 views
Duplicated data from a select
I'm creating a function in Postgresql to bring data based on the user's name, but when I don't pass a name in the argument it should bring all the appointments independent of the name, but I'm getting ...
Best practices
0 votes
5 replies
102 views
What is the best way to remember which function to use for which situation?
So I am learning how to use SQL on Python and I sometimes struggle to remember which functions to use and how to remember to enter them correctly, compared to BigQuery and MySQL which are kind of ...
Advice
1 vote
2 replies
94 views
Starting out on GitHub to create a portfolio
Currently getting into SQL data cleaning and querying and looking forward to building dashboards and data visualization using BI tools. As a beginner, how do I start with GitHub to create a portfolio ...
1 vote
2 answers
146 views
Recursive CTE to return item where a descending table and an ascending formula meet
I want the recursive bit that goes down in values be the values of c in the pc table and up in values be the plus_one recursive formula until the value from plus_one is greater than the one coming ...
1 vote
2 answers
143 views
XML format from SQL data table
I need to build the following XML data structure. I get the XML structure that I need but I am missing the student tag. <users> <user> <id>123</id> <name&...
0 votes
1 answer
61 views
On Update Cascade not cascading in child table [closed]
I have a parent table created by the following statement: Create Table "GL_Cash_Book" ( "y_trans_code" Integer Not Null, "trans_date" Integer Default ...
-2 votes
1 answer
99 views
Avoid quoted JSON output in SQLite
I have a query on my SQLite3 database where one of the columns results in JSON, produced via the built-in JSON functions. When I set the output format to JSON as well, I would have expected that this ...
Advice
0 votes
2 replies
64 views
Editing SQL view to include description
I have created the following view (below) now I need to edit it to include showing the WOTEMPLATEID as the DESCRIPTION: SELECT WOTEMPLATEID, COUNT(AR) AS Armondale, COUNT(CB) AS [Central Business ...
Advice
1 vote
9 replies
108 views
Does flipping from/to dates within date index make it more selective for SQL Server
In one of my projects I have an entity with startDate (from) and expiryDate (to): @Entity public class BlacklistedItem { //... @Column(nullable = false) private LocalDateTime startDate; @...