Skip to content
Advertisement

Tag: postgresql

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: Thanks in advance for any hint or

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

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: I need group tag names and server group names to be

How do I use one SQL statement to invalidate groups of records?

I’m working on an assignment for class. I need to write an SQL statement that returns every single country in the database where no single ethnic group makes up more than 25% of the population. This is the closest I can get: But, that only returns records where ethnic groups are over 25% population. It doesn’t remove other rows in

Advertisement