Documentation : https://prestodb.io/docs/current/functions/datetime.html I have epoch timestamps from which I want to extract week of the year like 2021-32, 2020-50, 2021-02 and so on. However I am getting up some wrong values like : week = 2021-53 for Epoch-Time corresponding to Jan 1, 2021 or Jan 2, 2021. I…
Tag: sql
How to add SUPER column to existing AWS Redshift table?
GOAL I would like to add a Redshift SUPER column to and existing redshift table. I need this to store JSON data there CODE This is how Normally I would add a new column. 1. Tried Error running query: ALTER TABLE ADD COLUMN defined as NOT NULL must have a non-null default expression Reviewed Solutions Alter co…
Access number identical fields with decimal number
I have a Table in Access and some field values are identical. If the field values are identical I want to have them numbered with decimal numbers. Is there a way to do this with SQL? Below is an example of my table and what I want to do. Answer You can use a query having two subqueries: Output:
How to not have time be a bind parameter in SQL, but have a parameter be bound?
I wish to select orders from after 23:00:00 but have a prompt for date selection, but when I use bind parameters the time is recognised as a parameter for binding since it contains “:”, what is a workaround for this? I need just OrderDate to be a bind parameter. Screenshot showing bind parameters …
SQL Merge Into with multiple statements
I’m trying to keep a historic table of another one. When updating the original I would like to insert rows into the historic one. I’m using Sql Merge: Can I make multiple statements in the same “when” condition?, as such: Answer Normally you can INSERT only into one table. The syntax d…
Can I combine more than one function in a single line in SQL?
What I want to do is simply to use more than 1 function in a single query. I’m new to SQL so I’m sorry if I’m getting some words wrong. select cognom from emp where length(cognom) = 10, replace(cognom, ‘ ‘, ‘*’); Answer Yes, you can, as long as you respect the syntax.…
Find Stored Procedure By Table Name (Oracle)
Need help. Every morning at 4 o’clock a table is created in the database, I need to understand what sources are used to create it, so I tried to find a stored procedure that creates this table using all_source or dba_source (select * from all_source where upper(text) like ‘%TABLE_NAME%’, but…
Search SQL database with multiple filters
I have the following code: This gives me the rows where “category_id” is equal to the 1. I now want the SELECT statement to return rows where the “category_id” is equal to one of the values I give it. So a simple SELECT statement would look something like this The problem is that I wou…
SQL query for last 365 days report
I have a reports table with the following structure : I want a SQL Query to get the report for the last 365 days by following conditions : Group dates if the same date is repeated. The days which the report is not available for the last 365 days, I need those days added to the result rows with 0
How to calculate sum of a value with only “day of week” using a date-range?
I have 2 tables namely Item table with details of item_id, store_id, offer_start_Date and offer_end_date Store table has store_id, day_of_week, store_hours The structure of both tables are follows – 1) Item_Table : Store ID Item ID offer_start_Date offer_end_date NY0001 FMC0001 2021-10-30 2021-11-04 NY0…