I wonder are there any way to get table access history in Redshift cluster? Our cluster has a lot of tables and it is costing us a lot. I would like to discover what specific tables have not been accessed for a given period and then I would drop those tables. Are there any ways to get table access history?
How to autofill a column with sequential number, but based on a parameter?
I’m trying to add a new column to few MySQL (MariaDB) tables. I want to make the column auto-filled with sequential number. What I figured out so far is: It works perfectly. However, I don’t know how to make it so that the order in which the numbers are assigned is based on another value, namely a…
Recursive query to get totals by distinct item from a row of a data
I have SQL data that looks like the following: How can I recurse through this data to get total wins, draws, losses by team for both home and away? My output would look something like: I was able to get this done in a very linear way by simply get a list of distinct teams and for each team looping
How do I update “case when” kogi mosi [closed]
Closed. This question needs details or clarity. It is not currently accepting answers. Want to improve this question? Add details and clarify the problem by editing this post. Closed 11 months ago. Improve this question I already have a table with some sample data. When I execute this I get: Error converting …
How to select data with percentages from Clickhouse?
Given the following table: I’m trying to fetch all statuses by host, with their relative percentage. In order to do that, I need to count results grouped by host and status, and divide each counted field by its total host fields count. For example, this query would have worked in MySQL: But ClickHouse t…
How to get particular name from logs
I have code where I am getting case details. Now I need to get LogAgent name for the case. But it is in the activity log table which have the columns CreatedBy, Type and this table has multiple rows (…
SQL: Match a variable value with multiple columns and select matching column name
I want to get the record with matching phone number. There are total 3 columns that saves phone numbers. Work, home and cellphone. I am writing a query to check if the phone number matches with any of …
Query to delete record when no matching in delta table
please help to write a better delete query. DB2 does not have “not matched by source” with merge. Need to delete rows which does not have matching codes from source file for an ID and need to delete rows only for the ID’s present in source file. sample data row with value ID=1 & code=IJK…
SQL CASE that matches value or uses LIKE ‘%’
I’m trying to do a wildcard retrieve if a defined variable is blank. But I can’t figure out the correct syntax. Answer It is as simple as this: The expression NULLIF(x, ”) will convert ” to null. Then we take advantage of how null comparison works: If @customerID is not null then first…
Pivot and Sum in Amazon Redshift
I have a following tables table1 table2 first I’d like to join table2 as follows and then join table2 with id and pivot and sum up them I guess it is very complicated, are there any way to achieve this? In Redshift it seems that there is no way to pivot them. Thanks. Answer This looks to be a pivot