How could I count data in range which could be configured Something like this, Table ZONE_CFG is configurable, so I could not use static value for this The DATE column mean maximum date for each ZONE And the result what I expected : Please could someone help me with this Answer You can use LAG and group by as…
What am I doing wrong in this where statement?
I’m using the following logic in my where statement. If I do just the statement below then it returns results However if I expand on the where logic to the following statement it returns no results. Why? Shouldn’t it return the same thing as where statement above? Basically what I want is the foll…
Roll up multiple rows into one postgresql
There is a role table How do I get the output as using SQL query : Answer Please try below query for your problem and let me know if still you are facing any issue.
Postgres Import from different table
I’m still fairly new to postgres. I have a table named: university_table with fields: name, nationality, abbreviation, adjective, person. I found this sql query to insert data from: https://stackoverflow.com/a/21759321/9469766 Snippet of query below. How can alter the query to insert these values into m…
PrestoDB/AWS Athena- Retrieve a large SELECT by chunks
I have to select more than 1.9 billion rows. I am trying to query a table hosted in a DB in AWS ATHENA console. The table is reading parquet files from the a S3 bucket. When I run this query: My query seems to time-Out as there are 1.9 billion rows that are returned when I run a COUNT on
Create a calendar database table like this
I would like to create a calendar SQL table like this one but for some years. (I’m using mysql 5.7.28) Date is DD-MM-YYYY Is it possible? Answer If you are running MySQL 8.0, you can use a recursive query: The recursive cte generates a list of datetimes between the given boundaries (here, that’s y…
How to use GROUP BY which takes into account two columns?
I have a message table like this in MySQL. Messages in a recepient’s inbox are to be grouped by thread_id like this: My problem is how to take recipient_read into account so that each row in the result also show what is the recipient_read value of the last message in the thread? Answer In the original q…
SQL: INSERT multiple different hardcoded values in one column
I could not find a solution for this yet. I want to insert multiple rows with 2 or more different hardcoded values, but also with data that I get from another table. Example: I want to add 2 items into a table for a user that has the ID = ‘0’ in another table without running 2 queries. This is
SQL Group By Column With Latest Date
I Have a table of following column name where we have date multiple bin have multiple date with 30-sec date slot I need to pull data based on last entry respect to bin Suppose 1990025I have 100 entry for today only when I query I need last enter record when I do get find All Entry group by bin am
Why I am getting error while performing group by in hive?
I am executing below command in hive: Select child.data_volume_gprs_dl + child.data_volume_gprs_ul as data_usage, parent.file_name, parent.record_number from table1 as parent left …