I am trying to connect to a remote SQL Server DB from a Java application without success. I am able to successfully connect to that SQL Server instance from a SQL client for Mac called SQLPro for MSSQL However, if I try to connect from the Java application using those same credentials, I always get a Login fa…
Tag: sql
selected splitted value in oracle
I have two columns A, B in oracle where A value has values like that xx-target-xx xx any data but target is exists i neet to return only ‘target’ from text i tired this but the result returns xx not target Answer Use REGEXP_SUBSTR. You want the second string of any characters except the minus sign…
Select id of user for specific email, or max(id)+1 if email doesn’t exist
I want to get the id of a user for a given email, or if the email doesn’t exist, I want it to return MAX(id)+1. So for the example below, I want: For email ‘aaa@gmail.com’, I want it to return 1 For email ‘kkk@gmail.com’, I want it to return 9 I made an attempt but I couldn’…
ORA-00937: not a single-group group function Workaround
This is my query which produces this error: ORA-00937: not a single-group group function Expected result for the last column – first order of every customer: I know that I have to use GROUP BY clause to handle this error, but it seems rather inappropriate to group by all the other columns.. I know that …
Problem with creating a SQL view with multiple joins
I am trying to create a view which will be a base for Excel export in API. Basically, what it contains is information about particular projects. To said projects calculations can be added (it all happens on the form on frontend). Those calculations are called EBIT, EBIT+ and OVI. User can add either one, two …
How to replace the NULL value of the last row of a column with ‘Grand total’ while retaining ‘Total’ replacing NULL value in the same column?
Below is the table created and inserted values in it: Now I ran the following query: When you look at the query result, the last row of the Gender column has the value ‘Total’ in it. I want to replace ‘Total’ with ‘Grand Total’ only in the last row of Gender column while ke…
Update table wp_postmeta column meta_value where meta_key column equals certain value
I would like to update (divide the value by 100) in table wp_postmeta column meta_value where meta_key = price_cents eg. My code: UPDATE wp_postmeta SET meta_value = meta_value / 100 WHERE meta_key = price_cents; Above SQL statemant gives me error: #1054 – Unknown column ‘price_cents’ in …
How to generalize the JSON in stored procedure?
In my database, I have table called library which have columns like dependencies, email, alert, skipped and values are stored as I want to prepare JSON of these values which will look like as I have written have code as And my JSON doesn’t look like desired JSON I am not able to achieve correct json . C…
Finding Percentage of Unmatching Records
There are 2 tables, hometown (showing the hometown) and residence (showing the places that the residents live in the past 10 years). I want to find the percentage of the residents that lived or is living out of there hometown. A resident can live in multiple places, and the state_of_residence can be duplicate…
I want to get the updated Salary by EmpID
I have a column EmpID and Salary. I want to get the updated salary each EmpID. FIGURE 1 : ID EMPID Salary 1 00000 75000 2 00000 80000 3 00001 75000 4 00001 90000 5 00001 91000 6 00010 50000 7 00010 60000 8 00010 70000 This is my initial query that I created with specific EMPID 00000 : The