Skip to content

postresql query to check no. of documents is 4

I have a master table for applications and another table for documents upload, I want the count of applications which has 4 documents in document table. master application table=>application_ht_install and Documents table=>bescom_appl_upload_doc ack_no is the primary key for application_ht_install and f…

How to regex match multiple items

I have a reviews table as follows: r_id comment 1 Weight cannot exceed 40 kg 2 You must not make the weight go over 31 k.g 3 Don’t excel above 94kg 4 Optimal weight is 45 kg 5 Don’t excel above 62 kg 6 Weight cannot exceed 7000g What I want to select is the weight a r_id’s cannot exceed.

Stored Procedure not working with variables

I have a stored procedure as follows: When I run the above by passing the search variable as 04029125070527 I get no results. But if I edit my stored procedure as follows, I get a result. The only difference is in the above I’m trying to send the variable and in the second its hard coded (not what I wan…

Sql join, count references including zeros

I made a simple database containing two tables, ‘country’ and ‘human’: This query shows that nobody lives in Norway, but why it says nothing about Denmark? I am using MariaDB, but prefer solutions that works on other DBs too. Answer You typically GROUP BY the same columns as you SELECT…

SQL Update Multiple columns with counts

We currently have SQL update statements that works for our needs and updates the tbl_rprt table. Below are some of the update queries, there are several others like them. I was wondering if there was another way to get this done, maybe combining all of them into one SQL statement. #tbl_rprt is a report of all…

How to return T2 name based on data from T1?

T1 game T2 heroes T1 IDC = ID from T2 I need to return all heroes that have anything except null in POWER or in HP with LTIME != -1 Query should return ID and NAME from T2 for that heroes. In this example query should return: 236 MAX I tried this: Answer Your WHERE condition in the subquery is

Oracle sum group by column range with different starting points

I have below sample data. i want to find the total sum(amount) of each respective user_x but starting from sdate assigned to each user. the sdate in the respective users does not change What i have tried below returns all the results, i just want one line result for each user_x This is what i want How can i d…