I am querying names from two tables: And I get the result I want in a single column. Now I want to know if it is possbile to get the results in two different columns like: “names_from_data1”, “names_from_data2” Or another way to identify where each name comes from: data_1 or data_2 Ans…
Tag: sql
How to format a number in thousands in SQL
I’m trying to format a number like 238350.50 into “238” with SQL. I round to the nearest thousend using ROUND(number_x, -3) and it works fine but I can’t get rid of the hundreds digits. A few more examples of how the formatting should work: 499.99 becomes 0 500 becomes 1 1250 becomes 1…
Integrity constraint violation: unique constraint or index violation HSQLDB
For example if I add new Department(new BigInteger(“50”), “ODD”, “SPB”), all work, it values are insert into database. But if I want again insert for example new Department(new BigInteger(“50”), “ODDMOD”, “SPBMOD”), appear java.sql.SQLInt…
postgresql total column sum
SELECT I have a SELECT like this. I need to get something like the one shown above. That is, I need to get the total of one column. I’ve tried a lot of things already, but nothing works out for me. Answer If I understand correctly you want a result where extra row with aggregated value is appended after…
Getting value error for INT when posting DataFrame values to psycopg2
I’m trying to insert a data to postgresql from a dataframe like this But getting this error code My sql table was created like this Answer The error says what’s the problem – the program expects integer and you pass list of integers there. It’s because execute is used to insert single …
Need to update column from derived column of select statement
I’ve this below select statement. Over there I’ve 2 derived columns EmpContbtnWithoutTax and EmpContbtnWithTax I wanted to have that data permanently in that same table EmpPFContributionTest Need help to have that update query for EmpPFContributionTest table which update the respective rows of Emp…
MySQL Multiple Conditions in Grouped Data
I am trying to see how many users have clicked on an ad campaign and signed up afterwards. My Logging table has the columns IP, UserID, and Data (this has the $_GET info like utm_source = newsletter). A user may click a link in newsletter and then later sign up on my website (which is indicated when they have…
Using wildcard in bigquery project name
I am trying to extract some information from all tables in the SALES dataset. I want to run it for multiple clients. Each client has a big query project. Bellow query returns what I want for our London client. How I can use a wildcard to do the same query for the other 10 clients and union all in one
How to compare multiple rows
I have a table with data like following, want to return those group_id with unique data. Both group_id 3 and 4 have two component 123 and 456, so they are “duplicated”, we just need to return the smaller group_id, that’s 3. Also group_id 5 doesn’t have a duplication, it can be returned…
LEFT JOIN by closer value condition
I have this query In the second LEFT JOIN, I would like to change the second condition pob.year = proc.anno_eleccion so that it does not only search for the exact year when joining. Instead, I would like to get the closer year stored in my pob table. For example, the first year stored in pob is 2003, so I wan…