SV: Onfly, function generated ID for Select Query

2023-03-09 Thread Gustavsson Mikael
No, the result will be ordered by the window functions order clause so no additional ordering is nessesary. You can try this by changing it to OVER(ORDER BY product_name) KR Mikael Från: Durumdara Skickat: den 10 mars 2023 08:41:06 Till: Gustavsson Mikael Kopi

Re: Onfly, function generated ID for Select Query

2023-03-09 Thread Durumdara
Dear Mikael! Wow... that is it! Thank you! SELECT product_id, product_name, group_id, ROW_NUMBER () OVER (ORDER BY product_id) FROM products; Does this mean that I have to duplicate the order by clause? SELECT product_id, product_name, group_id, ROW_NUMBER () OVER (*ORDER BY product_id

Get more columns from a lookup type subselect

2023-03-09 Thread Durumdara
Dear Members! I use the subselects many times in my Queries to get some info (Name, etc) from a subtable. Sometimes I have to use it to get the last element. select t.*, ( select value from u join ... where ... order by id desc limit 1 ) as last_value, It is ok, but how can I get more

SV: Onfly, function generated ID for Select Query

2023-03-09 Thread Gustavsson Mikael
Hi, Is it something like row_number() you want? https://www.postgresql.org/docs/current/functions-window.html KR Mikael Från: Durumdara Skickat: den 10 mars 2023 8:12 Till: Postgres General Ämne: Onfly, function generated ID for Select Query Dear Members! I'm

Onfly, function generated ID for Select Query

2023-03-09 Thread Durumdara
Dear Members! I'm searching for a simple solution, like this: select GetIDForThisSelect(1, 1) as UID, * from anytablehasdoublestringkey join othertablehasnotuniqueintegerkey ... where Ok, I can make a sequence, but I don't want to use persistent data. It is enough to get 1...N as UID for th

Re: select (17, 42)::s.t2 into... fails with "invalid input syntax"

2023-03-09 Thread David G. Johnston
On Thu, Mar 9, 2023 at 12:46 PM Bryn Llewellyn wrote: > « > SELECT select_expressions INTO [STRICT] target FROM …; > > where target can be a record variable, a row variable, or a > comma-separated list of simple variables and record/row fields. > » > > In plain English, the "into" target cannot b

Re: select (17, 42)::s.t2 into... fails with "invalid input syntax"

2023-03-09 Thread Bryn Llewellyn
> david.g.johns...@gmail.com wrote: > >> b...@yugabyte.com wrote: >> >> r := (my_c1, my_c2)::s.t; >> >> If you write s.x there it will also work. > > Your first and third assignments are identical in syntax/nature. These are > both the first examples here[1] > > Yes, the behavior of INTO

Re: public schema grants to PUBLIC role

2023-03-09 Thread Dominique Devienne
On Thu, Mar 9, 2023 at 2:13 PM Laurenz Albe wrote: Hi, On Thu, 2023-03-09 at 10:34 +0100, Dominique Devienne wrote: > > Hi. I've recently realized via a post (or article?) from Laurenz that > the PUBLIC > > role has CREATE privilege on the 'public' schema by default (see query > below). > > I gu

find coumn name and his type with greatest size in bytes

2023-03-09 Thread Алексей Ефимов
Hello all! can you help, i need to write a query that displays column name with his data type that have maximum bytes length in row for every table in database: for example, for table employees with data: emp_id, emp_name, emp_dept, emp_surname 1 alexey 2trew

Re: crosstab

2023-03-09 Thread David G. Johnston
On Wednesday, March 8, 2023, Rosebrock, Uwe (Environment, Hobart) < uwe.rosebr...@csiro.au> wrote: > Hi List > > I like to use crosstab to pivot a long list of rows into columns, however > the column labels are created dynamically with the resulting column type > known. > > > > Is there a way pass

Re: public schema grants to PUBLIC role

2023-03-09 Thread Laurenz Albe
On Thu, 2023-03-09 at 10:34 +0100, Dominique Devienne wrote: > Hi. I've recently realized via a post (or article?) from Laurenz that the > PUBLIC > role has CREATE privilege on the 'public' schema by default (see query below). > I guess it can't be avoided? It can be avoided if you connect to "te

crosstab

2023-03-09 Thread Rosebrock, Uwe (Environment, Hobart)
Hi List I like to use crosstab to pivot a long list of rows into columns, however the column labels are created dynamically with the resulting column type known. Is there a way pass a list of names and types to crosstab (‘query’) as (<‘type list as strings in array’> ) ? In other words, Can I pa

RE: Blog post series on commitfests and patches

2023-03-09 Thread Tim Clarke
That’s excellent Chris, thanks very much for doing that. Concise, informative and targeted. Is there a mailing list for updates? -- Tim Clarke BSc (Hons), MBCS IT Director Direct: +44 (0)1376 504510 | Mobile: +44 (0)7887 563420 From: Chris Travers Sent: Thursday, March 9, 2023 3:24 AM To: pgsql-

Re: public schema grants to PUBLIC role

2023-03-09 Thread Christoph Moench-Tegeder
## Dominique Devienne (ddevie...@gmail.com): > Hi. I've recently realized via a post (or article?) from Laurenz that the > PUBLIC role has CREATE privilege on the 'public' schema by default (see > query below). I guess it can't be avoided? You could just use PostgreSQL 15: https://www.postgresql.

public schema grants to PUBLIC role

2023-03-09 Thread Dominique Devienne
Hi. I've recently realized via a post (or article?) from Laurenz that the PUBLIC role has CREATE privilege on the 'public' schema by default (see query below). I guess it can't be avoided? OK, then I'll REVOKE that privilege when creating a new DB. Like I already revoked the default CONNECT to PUB