Skip to content
Advertisement

Tag: select

SQL alias for SELECT statement

I would like to do something like Is it possible to somehow do the “AS my_select” part (i.e. assign an alias to a SELECT statement)? (Note: This is a theoretical question. I realize that I can do it without assign an alias to a SELECT statement, but I would like to know whether I can do it with that.) Answer

JOIN two SELECT statement results

Is it possible to join the results of 2 sql SELECT statements in one statement? I have a database of tasks where each record is a separate task, with deadlines (and a PALT, which is just an INT of days from start to deadline. Age is also an INT number of days.) I want to have a table which has

Return all duplicate rows

I’ve written this code to find duplicates and it works fine: The problem is, it’s returning just one of the duplicate rows. Is it possible to return all the duplicate rows? I’m guessing it may have something to do with the ‘GROUP BY’ but I’m not sure how to change it. I don’t want to delete the values, just return

SQL WHERE ID IN (id1, id2, …, idn)

I need to write a query to retrieve a big list of ids. We do support many backends (MySQL, Firebird, SQLServer, Oracle, PostgreSQL …) so I need to write a standard SQL. The size of the id set could be big, the query would be generated programmatically. So, what is the best approach? 1) Writing a query using IN My

Select 2 columns in one and combine them

Is it possible to select 2 columns in just one and combine them? Example: select something + somethingElse as onlyOneColumn from someTable Answer Yes, just like you did: If you queried the database, you would have gotten the right answer. What happens is you ask for an expression. A very simple expression is just a column name, a more complicated

Mysql SELECT CASE WHEN something then return field

I have two field nnmu and nnmi , and reverse, At first everything looks good, but somehow it mix up values, it work when nnmi and nnmu both are equal to 0, but when either value is 1 it returns nonsense. Any help? Answer You are mixing the 2 different CASE syntaxes inappropriately. Use this style (Searched) Or this style

Advertisement