Questions tagged [table-functions]

A function in a relational database system that does not return a single value or row, but an arbitrary number of them. In SQL, a call to a table function can usually be used instead of a table.

A function in a system that does not return a single value or , but an arbitrary number of them.

In , a call to a table function can usually be used instead of a table.

Table functions go by different names in different relational database systems, such as in .

94 questions
0
votes
1 answer

Crosstable on multiple rows in PostgreSQL

Hi I want to know how can do a pivot table with crosstable in a table like: user_id action time 1 a 2022-01-01 12:30 1 b 2022-01-01 12:40 1 b 2022-01-01 12:50 1 c 2022-01-01 13:00 1 c 2022-01-01 13:10 1 c 2022-01-01…
0
votes
2 answers

How can I write a pivot that takes this form of data to the result desired?

I have a table that looks like this CREATE TABLE foo (id, name, category) AS VALUES ( 1, 'name1.1', 'cat1.1.1'), ( 1, 'name1.2', 'cat1.1.1'), ( 1, 'name1.3', 'cat1.2.1'), ( 2, 'name2.1', 'cat2.1.1'), ( 2, 'name2.2', 'cat2.1.1'), ( 3,…
John Doe
  • 13
  • 2
0
votes
1 answer

How to use DDL statements inside java script UDTF in snowflake

I am trying to use DDL statement like select columns from tables inside java script UDTF.. I am able to achive inside plain UDTF as below create function returntable() returns table(COL1 varchar(100),COL2 VARCHAR(100),COL3 NUMBER(10,0)) as …
0
votes
2 answers

How do you install the PostgreSQL tablefunc extension?

I am not able to run the following command in my PostgreSQL server: CREATE EXTENSION tablefunc; When I run this command, I get the following error message: ERROR: could not open extension control file…
0
votes
1 answer

Django QuerySet way to select from sql table-function

everybody. I work with Django 1.3 and Postgres 9.0. I have very complex sql query which extends simple model table lookup with some extra fields. And it wrapped in table function since it is parameterized. A month before I managed to make it work…
gorodechnyj
  • 691
  • 8
  • 25
0
votes
1 answer

SQL: Apply and union table function recursively

I'm using SQL Server Management Studio 18. I have a function that takes a table name as a parameter and outputs a table with info about other tables that have the same columns in it. Each table has a different amount of columns (that are also in…
0
votes
2 answers

Oracle - Return a result set via a SELECTable function without explicit object / table types

I'm trying to find a simple and easy-to-maintain way to return a result set via a function that can be referenced in a SELECT statement like this: SELECT u.UserId, u.UserName, up.ProfileName FROM GetUser(1) u INNER JOIN user_profile up ON u.user_id…
ravioli
  • 3,749
  • 3
  • 14
  • 28
0
votes
1 answer

how to calculate the lift value of table in R?`

library(readr) data1<-read_csv(".../file1") data2<-read_csv(".../file2") table2<-table(data1$`_SEGMENT_`,data2$`_SEGMENT_`,data1$Subscribed) This is the frequency table2 I created with three variables, data1 segment as row, data2 segment as column…
Jason Liu
  • 7
  • 2
0
votes
1 answer

How to edit records in SQL-Server stored procedure

I would like to know the secret of how SQL statements in SQL-Server go from being read-only to editable. Right click on any table, and the interface gives the option of "Selecting" or "Editing" records. Is there a property in the SQL statement…
0
votes
1 answer

How to overcome grouping() function not supported by HANA Table UDF?

I have written some custom logic in HANA anonymous block. I used grouping function somewhere in the middle as a core. It worked well and the result was satisfying. Once I tried to industrialize it by moving to HANA Table Function, the activation…
wounky
  • 97
  • 1
  • 12
0
votes
1 answer

Consuming Oracle Table Function from Stored Procedure

I'm working with an ERP database that stores a lot of data in multi-year tables. (Each new year a new table is created to hold the data for that year) We have a requirement to be able to query and report on some of these tables. I am currently…
PlasmaX
  • 15
  • 5
0
votes
1 answer

Is there any way to call PostgreSQL tablefunc module in R?

I have some PostgreSQL/PostGIS tablefunc queries that I want to call in R environnement. Is there any way to perform this? Ex : dbGetQuery(con, "SELECT * FROM CROSSTAB( 'SELECT factor1, factor2, ROUND(SUM(ST_AREA(geom))::numeric, 3) FROM table GROUP…
Rob Lucas
  • 67
  • 8
0
votes
0 answers

SQL Server 2012: Procedure is taking very long time to execute when I call a function within it with parameters but it doesn't if a pass raw values

I am asking wondering if any of you can help me with ideas. You see, I am tuning a store procedure, call it proc1, and it calls internally a table function. The procedure have a table input parameter (idk why, but it was build like that) and then it…
Negarrak
  • 375
  • 1
  • 4
  • 11
0
votes
1 answer

Check existence of given text in a table

I have a course code name COMP2221. I also have a function finder(int) that can find all codes matching a certain pattern. Like: select * from finder(20004) will give: comp2211 comp2311 comp2411 comp2221 which match the pattern comp2###. My…
Lilac Liu
  • 49
  • 1
  • 4
0
votes
1 answer

How to get dynamic number of columns in Postgresql crosstab

I'm new to the postgresql crosstab function and have tried out a few solutions here on SO but still stuck. So basically I have a query that result in an output like the one…
Clint_A
  • 518
  • 2
  • 11
  • 35