Using Qubole I have Table A (columns in json parsed…) I need to Select only IDs which have Recommendation GOOD but Decision BAD. Therefore output should be 3. I tried : Answer Use analytic functions. Demo: Result:
Tag: sql
mathematical operation between two select statements
I’m currently trying to find the percentage of certain amount of preregistered users in my postgres db, the operation would be (1185 * 100) / 3104 = 38.17. To do that I’m using two select statements to retrieve each count, but I’ve been unable to operate between them: This is what I have: Th…
query list of users after specified id in sqlalchemy.Table
Letss say that we have 10000 users on this data table. If the table is ordered by registration_date and I have a user id, how can I query the next 2 users after that id. e.g if this is the db table and I have the user id 1703, I want to get the next two users in the list.
why subtracting two time doesn’t work properly in oracle
I want to calculate system time till that day 17:00 in minutes in plsql, and I write the below query but it doesn’t work : can someone help me? Answer My guess is that you want If that isn’t what you want, it is helpful to provide some details and a test case to show exactly what you want to
How to query across multiple databases
I have a set of data that belongs to two different tables in two different databases. I have performed the query but I am getting a syntax error. The two databases are: This is what I am doing: Why would it give me an error on this part? as the syntax appears correct Any help is appreciated. Answer This Back.…
Is there a way to pair entrys by rows to give pairs such that there is maximum overlap by columns?
Sorry, for the poor phrasing. I am struggling to find a good way to describe this problem, so I will go with an example. Say I have a bunch of people that I need to pair up together based on similarities between rows. If my data looked like something below, how would I go about pairing people up by the
ppgsql declaring variable from parameter
I am running a sql query from the command line where I pass in value called tablename: I then set the variable like this: And then I have a function where I want to use the variable tablename like this: I have also tried declaring the variable with a few variations of this: Please let me know if you have
Update rows limit in Snowflake
I there a way to update values for top-n/limit amount of records in Snowflake? Sample data, top rows are the ones that need to flaged: The logic must combine SELECT n FROM limit 200 with SET FLAG = 1 Below syntax is not working: Answer If you need to update only a limited number of rows, you can try this
Postgresql unique constraint for colums of multiple related tables
I have the following tables: server (server_id as PK) server_groups Each server can have multiple server groups, every group name within a server must be unique. group_tags Each group can have multiple tags, a tag can be connected to multiple groups. Each tag name must be unique. group_tag_relations Problem: …
Calculate Median for each group in AWS Athena table
Below is the schema for the athena table I wish to calculate median for ‘parameter_value’ group by standard_lab_parameter_name & units. For this I followed link : https://docs.aws.amazon.com/redshift/latest/dg/r_MEDIAN.html But on running the query It throws error Any help? Or if some alternat…