I have a database as the data table below. Its a standard Open High Low Close Database. I wanna select the date, start-time, end-time, max([high] over ***The period of time) , and Close Data Table date time high 20100104 94000 21850 20100104 94500 21903 20100104 95000 21875 20100104 95500 21855 20100104 10000…
Tag: sql
how to query get value without id
I want to get the value of the column regardless of the id of the table, because I want to use GROUP BY to concatenate them from the table : id_child id_master test1 test2 test3 1 1 1 1 0 2 1 1 0 0 3 1 1 0 0 4 2 1 0 0 5 2 1 0 0
Round to nearest 15 minute interval
I’ve seen this question asked and answered for time that is stored as a date, but I have duration of hours and minutes stored as numeric(4,2). For example 2.12, is 2 hours 12 minutes. I need to round that to the nearest 15 minute interval, doing this (CONVERT([numeric](4,2),round(2.12/(25),(2))*(25))) d…
Impala convert string to timestamp always returns to NULL
I want to convert dd/mm/yyyy hh:mm:ss string to date format. this is not converting the string to timeformat and always returns me NULL. Please guide where I am going wrong. Answer You need to use correct format. The pattern string supports the following subset of Java SimpleDateFormat. A date string includin…
How can I introduce a has_one_belongs_to_one association in Rails model?
My Rails application has users and tasks created by users. Users can also create a task and assign another user to it. I am not quite sure how to build associations here. I know since a task is created by a user, I can have an association as below, I also want to add an association for creator in the
Parametrizing values to a snowflake query from another table
I’m trying to parametrize an update query reading values from a snowflake table as below. Snowflake query : srcTable : The values of col_name in above table – franchise, acct_type & pref_lang are actual columns of the tgtTable which Im trying to update based on old_val and new_val of srcTable …
How to use INSERT INTO — SELECT with new timestamp?
I’m working on a small website, that keep tracks of students information, When someone makes an update on one of the students I want to archive a copy of the previous record, I know that doing this makes a copy of the current data. But I want to include the date when the edit was made, so I tried this,
How to write DELETE Statement with Inner Query in PostgreSQL?
The below query works fine in Oracle DB. The same query fails in Postgres DB, but the inner query works fine in Postgres DB. I am getting syntax error for this. Error :- [Code: 0, SQL State: 42601] ERROR: syntax error at or near “(” Position: 13 [Script position: 3109 – 3110] How to fix this…
Database Error: NameError: name ‘db’ is not defined. What am I doing wrong?
On the web I found this illustration to create a database with gui with Tkinter. Everything ok, except when I enter the data and click on the Add button. I’m getting: NameError: name ‘db’ is not defined I think what I am wrong is nonsense in this part of the code. What am I doing wrong? Here…
SQl query to show the most popular category in terms of sales quantity for each country and each gender in year XXXX
There are Three tables here Orders, Customers and Items. Please tell me how to solve this. I have tried few combinations but were not successful. Thanks in advance. Answer In Mysql 8 you have ROW_NUMBER to select the “best” from a PARTITION country | gender | category | oYear | total :—̵…