Skip to content

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…

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.…

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: …