Skip to content
Advertisement

Tag: postgresql

Getting data from three tables in postgresql

I’m new to postgresql. I have three tables Table1: teacher Table2: school_location Table3: teachers_school_location I want to write a query to get data from these three tables like this: (output in json by calling an API) When user select tid = 1, I want output like this When user select tid = 2, I want output like this I used

sql query for stratified sampling with dynamic sample size

Let say we have a table in this format: From this example, we see two stratas s1 and s2. What I want to do is stratified sampling and the sample size is the last column. For example, I want to randomly sample 2 instances from s1 and 1 random sample from s2. Any help is appreciated. Please keep in mind

Advertisement