I have a couple of rows where values in one column are repeating and I need to get a couple of rows where every value is limited by const. For example, i have this rows (1, ‘a’) (2, ‘b’) (3, ‘a’) (4,’…
Eliminate duplication from a SQL query to avoid returning NULLs from a LEFT/RIGHT JOIN
Have this MS SQL query SELECT COUNT(*) AS Total, CASE WHEN COUNT(*) = 0 THEN 0 ELSE SUM(ISNULL(p.AmountGB, 0)) END AS AmountGB, CASE WHEN COUNT(*) = 0 THEN 0 ELSE SUM(ISNULL(p.TaxAmountGB, 0)) END AS …
How to fix my postgres function syntax to fit a user parameter
I’m trying to make a postgreql function, I’m a little confused on which syntax format to use when I’m passing a select statement that takes in a parameter (this parameter can be a string or a list of …
concatenate timestamp to date
I have set of timestamps: how I can concatenate it to dates? expected: Answer You would cast it to a date and the use distinct to get the distinct dates
How can I create summaries across columns?
I have an existing application database table supporting an application, and I’ve been tasked with adding another feature. Currently, we have a build table that stores information about product builds….
How to create generated columns in DB2/400
I wanna create a virtual column which concatenates two columns to 1. My attempt was: This should work according to the docs. ( https://www.ibm.com/support/knowledgecenter/ssw_ibm_i_73/db2/rbafzpdf.pdf?view=kc ) (page 851). Has anyone an idea how to get this done? Thanks in advance. edit: I doublechecked it. This doesn’t work either. Answer Always give your Db2 version (or in this case , the version
Why ROW_NUMBER is defined as window function?
I would like to understand better the meaning of window function. The definition says: A window function performs a calculation across a set of table rows (the window) that are somehow related to the current row Let’s consider ROW_NUMBER() (the same could be applied for RANK() or DENSE_RANK()). The function simply assign a number to an ordered set of rows.
MySQL use JSON_CONTAINS with a subquery
I’m trying to make a subquery inside JSON_CONTAINS to have a results like this This is what I have tried But since the subery query returns Client instead of “Client” JSON_CONTAINS doesn’t accept the value. ERROR 3141 (22032): Invalid JSON text in argument 1 to function json_contains: “Invalid value.” at position 0. Answer You could just concat the double quotes
Sum two column values on the basis of two name column
I am new to Postgres database. I am given 4 columns homeTeamName, homeTeamGoals, awayTeamGoals, awayTeamName. I want to find out the total goal(homeTeamGoals + awayTeamGoals) scored by each team. the database is as follows I think my solution is wrong. So looking for a better way Answer You can separate the table content as below, and then apply SUM function
SQL Server – Dsiplay all rows from LEFT table even when the condition is not met
I want to get all Titles and Scores for a Given skill Id, every skill has titles mandatorily but there may not be records in the Answer table matching the condition A.[ServiceId] = 45 in this case i still need to display all the Titles and 0 as score For this purpose i made LEFT Join and still it doesn’t