Problem I want to group my data by currency, timestamp and show all type value like table of comparison with interval of 30 minutes, for now my created time is 1 minute or less different so if i group with created time it will still showing 4 rows cause of different timestamp, is there a way to round the timestamp
Tag: postgresql
Generate random date into series [closed]
Closed. This question is not reproducible or was caused by typos. It is not currently accepting answers. This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers. Closed 11 months ago. Improve this question
Generate 100 rows with random data using SQL query
I use this SQL query to insert 1 row of data: Is it possible with 1 SQL query to insert 100 rows with random data into Postgre table? Answer
Find Individuals who have purchased 10 times within a rolling 1 year period
So let’s say I have 2 tables. One table is for consumers, and another is for sales. Consumers ID Name … 1 John Johns … 2 Cathy Dans … Sales ID consumer_id purchase_date … 1 1 01/03/05 … 2 1 02/04/10 … 3 1 03/04/11 … 4 2 02/14/07 … 5 2 09/24/08 … 6 2 12/15/09 … I want
PSQL timestamp – how to include microseconds?
How can I create an SQL timestamp from an ISO timestamp that includes microseconds? e.g. select to_timestamp(‘2021-08-29T16:32:25.336239Z’,’yyyy-mm-ddThh24:mi:ss.usZ’) will result in 2021-08-29 16:32:25 – microseconds precision lost. Answer You can use ISO timestamps directly: The TIMESTAMP ‘YYYY-MM-DD HH:mm:ss.nnnnnn+offset’ is the standard ANSI SQL format, which PG supports, and they also support ISO8601 in addition to it, since the difference is minimal.
postgres syntax error on grant select on table
I have a query: But on running this: I get the following syntax error: without grant query its working fine. What am I missing here? Answer To specify the schema, use ON public.abc. The syntax IN SCHEMA public can only be used with ON ALL TABLES. Also, you have to separate CREATE TABLE and GRANT with a semicolon, as they
Arranging VARCHAR data into Columns in SQL
My data is in a SQL table in the following format (I have about 20 different answers per user_id): I would like to create a view in PostgreSQL where all the data is shown according to User ID Thank you! Answer It is great example of not relational data (the semantic depends on row number), although the data are saved
join two sql table as column
i have two tables as below: firsttable id cat_id name 1 2 name_01 2 2 name_02 3 1 name_03 4 3 name_04 5 3 name_04 secondtable id name 1 cat_01 2 cat_02 3 cat_03 my question is how can i create below table result? id(secondtable) name(secondtable) count(firsttable) 1 cat_01 1 2 cat_02 2 3 cat_03 2 Answer
Postgres transpose a row
I have a table which looks like the following :- I want to transpose it to the following form, in Postgres: I know I’m supposed to use the pivot operation to do this, but I can’t figure out the right syntax to get this done. Any help to get this done will be appreciated. Answer That would simply be: but
How to use pg_dump correctly in order to do a database migration?
Hey everyone I am fairly new to doing a pg_dump in Postgre sql. I have logged into the server and am running as postgres user. I try to run the pg_dump in order to do a database migration but I keep getting a “Permission Denied” prompt. I believe that I have the highest permissions and should be able to run