where-clause

Hive - Where and OR clause error

守給你的承諾、 提交于 2021-02-08 05:55:48
问题 Hi I am trying to run this query in Hive, but get the error 10249 (Unsupported query expression - only 1 subquery is supported...) select count(*) from ( select * from tableA union all select * from tableB ) a where a.field1 in (select fieldA in tableC) or a.field2 in (select fieldA in tableC) or a.field3 in (select fieldA in tableC); Would anybody know how I can write this so that Hive supports this query (works fine in SQL server) 回答1: Since you do not need fields from tableC , you can use

how to avoid column in 'where' clause if parameter is 'NOT PASSED' postgresql

穿精又带淫゛_ 提交于 2021-02-08 03:32:08
问题 Running Query : select * from employee where name = $1 and age = $2 and salary = $3; Problem Query : select * from employee where name = $1 and age = $2; How can I write A Logic That /* If $3 is PASSED Then ( and salary = $3 ) */ Note : /* I Cannot check For null or Empty as $3 as not passed then $3 won't be available for check* / In Node I Am using Like This postGresAdaptor.executeQueryWithParameters(QUERY, QUERYPARAMS, function(error, result) { if (error) { callback(error); } else { data =

Aggregate functions in WHERE clause in SQLite

筅森魡賤 提交于 2021-02-06 10:43:18
问题 Simply put, I have a table with, among other things, a column for timestamps. I want to get the row with the most recent (i.e. greatest value) timestamp. Currently I'm doing this: SELECT * FROM table ORDER BY timestamp DESC LIMIT 1 But I'd much rather do something like this: SELECT * FROM table WHERE timestamp=max(timestamp) However, SQLite rejects this query: SQL error: misuse of aggregate function max() The documentation confirms this behavior (bottom of page): Aggregate functions may only

WHERE clause great than zero still showing zero when using CASE functions

泪湿孤枕 提交于 2021-02-05 11:19:26
问题 I am trying the WHERE clause to filter out other data I dont want. SELECT `post_id`, MAX(CASE WHEN `meta_key` = 'vlaue_1' THEN `meta_value` ELSE NULL END) as 'Customer', MAX(CASE WHEN `meta_key` = 'value_2' THEN `meta_value` ELSE NULL END) as 'DeliveryDate', MAX(CASE WHEN `meta_key` = 'value_3' THEN `meta_value` ELSE NULL END) as 'DeliveryTime', MAX(CASE WHEN `meta_key` = 'vlaue_4' THEN `meta_value` ELSE NULL END) as 'DeliveryType' FROM wp_postmeta WHERE 'Customer' > 0 GROUP BY `post_id`

Get Employees Who Are Below Average Salary After A Raise

与世无争的帅哥 提交于 2021-02-05 09:03:00
问题 I need to get fname, lname, salary of employees who are $400.00 below the average salary even after geting a 10% salary raise. I'm able to get employees who's salary is below the average salary, but am unsure how to get those who are $400 below after a raise. I'm using MySQL. Thank you. select AVG(salary) from employee; #gives me the average salary select Fname, Lname, Salary, 1.10*Salary as NewSalary from employee; #gives me names, old salary and salary raised. This gives me the employees

Find records in deeply nested associations with rails

▼魔方 西西 提交于 2021-02-05 07:14:25
问题 I have the following models: class Book < ApplicationRecord has_many :chapters end class Chapter < ApplicationRecord belongs_to :book has_many :pages end class Page < ApplicationRecord belongs_to :chapter has_many :paragraphs end class Paragrpah < ApplicationRecord belongs_to :page end Now I want to get a list of all paragraphs in a specific book. Something like: @parapgraphs = Paragraph.pages.chapters.book.where(:title => 'My Book') When I do this, I get: undefined method 'chapters' for

column_property (or other extra column) with window function?

拟墨画扇 提交于 2020-12-15 06:29:34
问题 I have the following situation, using SQLAlchemy with a MySQL database. Assume a Person table that looks like this: +------+-----------+----------+------------+ | ID | firstname | lastname | startdate | +------+-----------+----------+------------+ | 43 | Bob | Smith | 2016-12-04 | | 873 | Mary | Jones | 2018-05-01 | | 120 | Bob | Smith | 2020-04-02 | | 339 | Bob | Jones | 2019-03-01 | | 1022 | Bob | Smith | 2015-11-21 | +------+-----------+----------+------------+ I need to generate an extra

column_property (or other extra column) with window function?

送分小仙女□ 提交于 2020-12-15 06:27:29
问题 I have the following situation, using SQLAlchemy with a MySQL database. Assume a Person table that looks like this: +------+-----------+----------+------------+ | ID | firstname | lastname | startdate | +------+-----------+----------+------------+ | 43 | Bob | Smith | 2016-12-04 | | 873 | Mary | Jones | 2018-05-01 | | 120 | Bob | Smith | 2020-04-02 | | 339 | Bob | Jones | 2019-03-01 | | 1022 | Bob | Smith | 2015-11-21 | +------+-----------+----------+------------+ I need to generate an extra

Speeding up count(distinct) of one column based on condition on other column in MySQL

拥有回忆 提交于 2020-12-13 03:34:26
问题 I have a MySQL table of 10 million rows and 3 columns, in following format: +---------------------------------------------------------------------------------------+ | id time num | +---------------------------------------------------------------------------------------+ | ca65e871-d758-437e-b76f-175234760e7b 2020-11-14 23:08:05.553770 11112222222 | | ... | +---------------------------------------------------------------------------------------+ For running the first query below, I indexed

Speeding up count(distinct) of one column based on condition on other column in MySQL

生来就可爱ヽ(ⅴ<●) 提交于 2020-12-13 03:34:21
问题 I have a MySQL table of 10 million rows and 3 columns, in following format: +---------------------------------------------------------------------------------------+ | id time num | +---------------------------------------------------------------------------------------+ | ca65e871-d758-437e-b76f-175234760e7b 2020-11-14 23:08:05.553770 11112222222 | | ... | +---------------------------------------------------------------------------------------+ For running the first query below, I indexed