Skip to content

Drop Several Tables at Once

I have some tables that I need to drop on a regular basis. The names of the tables sometimes change but the table names always begin with ‘db_comp_temp’. Is it possible to write some SQL that will in effect do something like: Thanks in advance, Answer No, there is no wildcard support in DDL. Or: Y…

How to know location about partition in hive?

If I write a hive sql like ALTER TABLE tbl_name ADD PARTITION (dt=20131023) LOCATION ‘hdfs://path/to/tbl_name/dt=20131023; How can I query this location about partition later? Because I found there …

Formatting a variable as a string

I am trying to create a Python program that will query a URL and produce a JSON file. I need to pass an argument in the end of the URL which comes from the SQL query. I have imported the requests …

Select by -3 days?

I’m trying to select data from a specific table in my database, but I want to be able to only view the last 3 days worth of data, I have the following code but for some reason I can’t get it to work. Answer You may avoid usage of DATE_ADD() at all: As @OGHaza mentioned, you specified column with a…

Return All Months & Years Between Date Range – SQL

I’m a bit stumped how I might go about this. I have a very basic query, that currently returns sales for each product, by year and month. It is grouping by year/month, and summing up the quantity. This returns one row for each product/year/month combo where there was a sale. If there was no sale for a m…

sql-ex exercise 39 failed on second server error?

Exercise 39: Define the ships that “survived for future battles”; being damaged in one battle, they took part in another. Database Schema: http://www.sql-ex.ru/help/select13.php#db_3 My approach: sql-ex says Your query produced correct result set on main database, but it failed test on second, che…