Question: Why is this query returning an error. I am trying to load the code for table as a constant string, the flag for data again a constant string, the time of insertion and the counts for a table. I thought, let me try and run the secelct before writing the inserts.
But for some reason, it fails listing column names from tables from where I am trying to get a count. All i need is two constant values, one date and one count. Tried by removing the groupby as well, throws another error.

**hive -e "select "WEB" as src\_cd, "1Hr" as Load\_Flag, from\_unixtime((unix\_timestamp(substr(sysDate, 0, 11), 'dd/MMM/yyyy')), 'MM/dd/yyyy') as time, count(\*) 
from weblog
where year=2015 and month=04 and day=17
group by src\_cd, load\_flag, time
;**
"

OK
Time taken: 1.446 seconds
FAILED: SemanticException [Error 10004]: Line 4:9 Invalid table alias or column reference 'src\_cd': (possible column names are: clientip, authuser, sysdate, clfrequest.........(and so on) year, month, day)

Answer: 
Just leave out the constants in the `group by`. It isn't doing anything:

```
select "WEB" as src_cd, "1Hr" as Load_Flag,   
       from_unixtime((unix_timestamp(substr(sysDate, 0, 11), 'dd/MMM/yyyy')), 'MM/dd/yyyy') as time, count(*)
from weblog
where year = 2015 and month = 04 and day = 17
group by from_unixtime((unix_timestamp(substr(sysDate, 0, 11), 'dd/MMM/yyyy')), 'MM/dd/yyyy') 

```

I don't think Hive allows column aliases in the `group by`, so you need to put in the entire expression or use a subquery/CTE.
There are two things.
1. Hive does not parse double quote or single quote in that way. So instead use back quote(`).
2. In group by clause either use the columnar position specifier or the direct functional translation.