Skip to main content
Filter by
Sorted by
Tagged with
-4 votes
2 answers
82 views

How to make this subquery return more than one row?

I select data from temporary table: CREATE TEMPORARY TABLE IF NOT EXISTS "tmp" ( "fuel_type" TEXT, "litres" NUMERIC(8,2), "is_rent" BOOLEAN ); ...
Ascerd's user avatar
  • 1
0 votes
1 answer
27 views

supabase function unable to access one table

I have a function in supabase that updates two tables (Messages and Games), I've now added a third (Users) and for some reason its unable to access it, I've added a debug_logs table to figgure out ...
Ben Klino's user avatar
-3 votes
2 answers
69 views

When i call this function for 700k record it is very slow

When I call this function for 700k rows it is very slow. This function calculates the number of holidays between two dates. ALTER FUNCTION [dbo].[HolyCount] ( @StartTime datetime, @...
Adel's user avatar
  • 29
0 votes
1 answer
108 views

Why were functions introduced when stored procedures were already available in SQL Server?

What factors led to the introduction of functions alongside stored procedures in SQL, and how do functions specifically enhance the flexibility and efficiency of database operations compared to stored ...
Mridul Thakur's user avatar
0 votes
1 answer
43 views

JSON_KEYS function

in the JSON_KEYS function, i dont understand what is return type: https://docs.singlestore.com/cloud/reference/sql-reference/json-functions/json-keys/ according the doc : Return Value: A JSON array ...
Lukas Pistelak's user avatar
0 votes
0 answers
100 views

Create SQL function using Django migrations command

I am using Django Framework in Python with MySQL Database For adding a table in the database, I create a class in models.py and then run python manage.py makemigrations. This creates the migration ...
Charmi's user avatar
  • 37
-2 votes
2 answers
111 views

Get particular value from string in SQL query

I am working with a stored procedure where I am getting a string with different characters I want to get a value at last index [AV] Z_Prem_454-3000_XXXXX_800+ [InstalmentScheme 6] above is the string ...
Pratex's user avatar
  • 115
0 votes
1 answer
78 views

Why is the explicit table name necessary in this Postgres Function?

I'm using Postgres for the first time and am confused by an "ambiguous" error regarding my functions. CREATE TABLE "user" ( user_id VARCHAR(40) PRIMARY KEY, email VARCHAR(...
Tristan's user avatar
  • 1,760
0 votes
0 answers
373 views

How to pass Table Name as a parameter in Databricks SQL?

I am trying to create a function which takes some values and table name as a parameter and returns 1 or 0. The function is not replacing tableName with the parameter and hence throws an error. I am ...
Priyam's user avatar
  • 11
0 votes
1 answer
214 views

How do I create a PostgreSQL TRIGGER to automatically calculate columns after INSERT?

I am trying to populate some calculated columns after each new row INSERT in PostgreSQL, but I can't get it to work. I have already read these posts (I know these are for SQLite - this question was ...
skeetastax's user avatar
  • 1,488
-2 votes
1 answer
75 views

Syntax Error #1064 when using MariaDB JSON_REPLACE function

I'm using MariaDB version 10.3.39. I have create a table named "sys_config" with multiple columns. A column name is "json_system". It's data type is assigned to "longtext"...
Scott Jennings's user avatar
0 votes
0 answers
108 views

Error: No function matches the given name and argument types. You might need to add explicit type casts

To fetch the result, and search functionality, I took the approach of writing SQL Function and use it in the spring boot backend, using native query. To do that I have created a function as shown ...
MightyThor's user avatar
0 votes
1 answer
31 views

I need to treat values ​from a string field and break it down into an array

I have a table in bigquery with a string field that I need to read, disassemble and generate a new field with several rows receiving the disassembled field The field has values ​​like this: Column A ...
Paulo Medeiros's user avatar
0 votes
1 answer
33 views

SQL error getting counts of subscribes and unsubscribes number from 2 tables

I'm getting an error on this Presto SQL code in subscribes and unsubscribes function and variable names: SELECT emailaddress, firstname, lastnamename, role, status, optindate, ...
Pardeep Singh's user avatar
0 votes
1 answer
45 views

'column reference "id" is ambiguous' error on function call that uses RETURNING

I have this table with two autogenerated columns: CREATE TABLE driver_orders ( id SERIAL PRIMARY KEY, car_id INTEGER NOT NULL, location_from GEOGRAPHY -- generated GENERATED ...
ABDULLOKH MUKHAMMADJONOV's user avatar
0 votes
2 answers
78 views

How to use a query returning integers in an SQL function that returns integer[]?

I created a function that returns all values that meet the condition specified and tried specifying int[] as the result type of the function. create or replace function mults_of_3_5(id int) returns ...
Devansh Gupta's user avatar
0 votes
2 answers
29 views

String modification for table column values

I need a solution for string from column values like 'abc xyz-1234' to 'xyz, abc'. What will be the Oracle SQL query for above solution. SELECT SUBSTR (COLUMN_NAME, INSTR (' ', ...
Amol Salunke's user avatar
0 votes
0 answers
33 views

Postgres plsql return one column from table with dynamic type

I'd like to create function using pgplsql which takes table name and column name and returns this column as result. The main problem which I faced is dynamic type of this columns (might be int/float/...
Philipp's user avatar
  • 27
1 vote
1 answer
280 views

Processing data row by row while bulk insert using JSON in SQl server

Need to Generate Tag Number While Inserting Data using JSON in SQl Server Stored Procedure. I have 2 Tables Table1: Category (lastusedIndex null in initial stage) Id categoryname assetPrefix ...
Relax's user avatar
  • 327
0 votes
2 answers
54 views

How to identify the value which was assigned before the present value that is assigned?

There are multiple historical rows present for a customer in customer table and a id has been assigned which might have changed overtime Name ID Date Abhishek 1 23-08-2023 Abhishek 1 03-08-2023 ...
smriti mishra's user avatar
1 vote
1 answer
225 views

Using the SQL LAG() function

I'm trying to use the LAG function in SQL to attempt this but I'm unsure if I am using this incorrectly or not. What I am trying to do is where you see a NULL under the LOCAL_ID column, fill that NULL ...
Sunny0101's user avatar
  • 476
1 vote
2 answers
240 views

Can I use an OPTION clause inside a function in T-SQL (SQL Server)?

I want to write a function like this: CREATE OR ALTER FUNCTION TestFunction() RETURNS TABLE AS RETURN WITH NumberList AS ( SELECT 1 AS Number UNION ALL SELECT Number + 1 FROM ...
Daniel Jonsson's user avatar
0 votes
2 answers
142 views

Find the least value in between the columns using Spark DataFrame

I have a dataframe like below and need to find the least value except zeros and add it in a new column as 'Least'. Column1 Column2 Column3 100.0 120.0 150.0 200.0 0.0 0.0 0.0 20.0 100.0 I tried ...
RMK's user avatar
  • 17
0 votes
0 answers
62 views

Function validate email SQL informix

I need to do a function in an older version of informix that I need to validate a mail: so I need a function that check the email pattern [a-zA-z0-9]@[a-zA-Z0-9].[a-zA-Z0-9] Also in the last one that ...
Martí Castell's user avatar
1 vote
1 answer
916 views

Count of rows in pyspark dataframe over a window

I have a pyspark dataframe with below data [ My code: W = Window.partitionBy("A").orderBy(col("C")) main_df = main_df.withColumn("cnt", F.count("B").over(W)) ...
Passive_coder's user avatar
0 votes
1 answer
70 views

MariaDB functions cannot correctly retrieve data from INFORMATION_SCHEMA.COLUMNS

I want to create a function in SQL that takes in a field name and field type and returns a boolean value. Based on the result, I will decide whether or not to update the field type. Here is the code ...
Zheng Li's user avatar
3 votes
2 answers
59 views

Postgresql - error returned more than one row from function

My first post in Stackoverflow. I am trying to learn Postgresql (12) "on the job" and seem to be stuck on a rather simple issue. I have a simple database with 12 rows. In one column (int) ...
James's user avatar
  • 43
-1 votes
1 answer
45 views

Why is the column value not persisting after Postgres function triggers after update?

I have a table called Projects where I need to set a certain column value after an update is executed and the record matches certain conditions. The function triggers correctly and there are no errors ...
Samuel Alito's user avatar
1 vote
1 answer
78 views

How can i write a postgres function that loops over array of arrays and concatenates all values into a string

I am trying to write a postgres function that takes an array of arrays (e.g. [[65.8434183140001,38.905535066],[65.8433595220001,38.905479615],[65.843286031,38.9054103],[65.843108611,38.9055251450001],[...
ABDULLOKH MUKHAMMADJONOV's user avatar
-3 votes
1 answer
94 views

Postgresql function has syntax error at If. Why?

I am new to writing functions on postgres. So I was trying to write a function that checks if a row exists. If it exists then it returns the row with a flag 'Exists', else it inserts a row and returns ...
Prajwal Abraham's user avatar
0 votes
3 answers
303 views

SQL Query to extract the numbers before a specific word, including floating point numbers

I have data like this: String 1: 'Random Text 3 Random 568 Text 5.5 Test Random Text 345' String 2: 'Random Text 3 Test Text Random' String 3: 'Random Text 777 Random Text' The output I expect is: ...
Lloyd Thomas's user avatar
1 vote
1 answer
74 views

when try to make database separated comma i get error invalid in the select list because it is not contained in either an aggregate?

I work on SQL Server 2012 I face error and I don't know how to solve error Msg 8120, Level 16, State 1, Line 43 Column '#servers.ServerId' is invalid in the select list because it is not contained in ...
ahmed abdelaziz's user avatar
-1 votes
1 answer
126 views

Function is not working with varchar records

I have a function that in theory will give the country name as output when the input is the city name: CREATE OR REPLACE FUNCTION public.country_by_city(city varchar, OUT Country varchar) RETURNS ...
lowercase male's user avatar
0 votes
1 answer
45 views

How to find the nearest numeric values (also in decimal places) in SQL same as LIKE function

I want to find the nearest coordinates to validate the place name as the format type is FLOAT, then I cannot use LIKE function as it is only applicable for STRING format. situation example; my ...
Syarqawi Ruslan's user avatar
0 votes
0 answers
104 views

How does SQL STBuffer measure distance around polygons?

How does the STBuffer function measure distances around a polygon? I am looking at the expression: select SP_GEOMETRY.STBuffer(100) and wondering how the 100-meter buffer is calculated around the ...
Hayley's user avatar
  • 1
2 votes
1 answer
135 views

Generate a sequence of square numbers till 10

How to generate a sequence of SQUARE numbers till 10 in MYSQL? (1^2,2^2, etc) I was only able to generate a numerical sequence from 1 to 10. WITH RECURSIVE cte (n) AS ( SELECT 1 UNION ALL SELECT ...
Mouse12328's user avatar
0 votes
1 answer
88 views

Trying to automatically insert into a table using triggers in POSTGRESQL

I am trying to make a trigger and function that inserts into the table purchases the values which have been inserted into the table customers. Columns of table customers 1-customer_id serial PK ...
user avatar
0 votes
2 answers
265 views

how can I make result of ARRAY_AGG() function json parsable

I have a query that selects the rows from joined table as an array using ARRAY_AGG() function. select entity_number, ARRAY_AGG('{"property_id":"'||property_id||'","...
ABDULLOKH MUKHAMMADJONOV's user avatar
0 votes
1 answer
92 views

POSTGRESQL How to return multiple rows from SQL function?

I'm new to databases and SQL and i've been messing around with functions on POSTGRESQL and I made a simple function to select all names from a table. But the function, when called, returns just a ...
user avatar
0 votes
1 answer
458 views

How to use the age() function in postgresql inside a CREATE TABLE block

I am trying to make a table called Citizens in postgresql using PGadmin and inside this table there is a column called ageand I want this age to be calculated and put inside this column when I insert ...
user avatar
0 votes
1 answer
1k views

Memoizable functions - Snowflake

When querying INFORMATION_SCHEMA or SHOW FUNCTION we could find a column IS_MEMOIZABLE. SELECT IS_MEMOIZABLE, * FROM INFORMATION_SCHEMA.FUNCTIONS; None of built-in function is memoizable: SHOW ...
Lukasz Szozda's user avatar
3 votes
1 answer
1k views

How to add trailing spaces when concatenating two columns?

I am trying to find a way to preserve a space within SQL concatenation. For context: A table I am selecting from a table with a single concatenated key column. Concatenated keys respect spaces. ...
Zero's user avatar
  • 1,602
0 votes
1 answer
60 views

postgres function for loop

I have an orders table and an order_products_items table. The order_products_items has these fields: order_id product_id quantity price I am trying to create a calculated_field: ...
Saif-Alislam Dekna's user avatar
1 vote
1 answer
69 views

SQL/PSQL function to get latest update from inner joined table

I have 2 tables: drivers and drivers_locations. I want to create a computed field in the drivers table that returns the last inserted location of a driver. The drivers_locations table has these ...
Saif-Alislam Dekna's user avatar
1 vote
2 answers
58 views

SQL get row count from every table tenantwise

I am working on a multitenant application. Most of the tables contain a column tenant_id. I want the number of rows in all tables for a particular tenant_id. Example, Tables:- create table Employee(id ...
Umesh Malhotra's user avatar
0 votes
0 answers
59 views

Trigger function for table with multiple joins PostgreSQL

I'm new to PostgreSQL and I didn't find any questions specifically for this issue. I'm trying to create a PostgreSQL trigger with a table which contains joins. Table A Salesman_id Salesman name 1 ...
Matheus Pombo's user avatar
0 votes
1 answer
388 views

Execute prepare statement in a sql function

CREATE OR REPLACE FUNCTION my_function2() RETURNS VOID LANGUAGE plpgsql AS $func$ BEGIN PREPARE "my-statement7" (text, text) AS INSERT INTO "...
Jack Wang's user avatar
0 votes
2 answers
35 views

How can i fix this problem with OR/AND clause in SQL

I have a set of patents that I have titles and abstracts on and would like to search in such a way that their final search algorithm requires the keyword “software” to be present, and none of the ...
Benimaru cpt's user avatar
0 votes
1 answer
2k views

Is there an equivalent function of unnest(postgresql) in mysql?

was working on a sql question which had a simple answer through unnest in postgresql but what i want to know is that can we basically solve it on same grounds in mysql too? question with the dataset ...
Shivam Madaan's user avatar
0 votes
1 answer
4k views

Snowflake - Processing aborted due to error

i am getting error while calling below procedure create or replace procedure get_net_profit_based_on_partition_value(part_value varchar) returns table (branch_id integer, city varchar, net_profit ...
AdhiHari's user avatar

1
2 3 4 5
19