Skip to content

Tag: sql

What is wrong with my Postgres statement?

I am trying to select list of employees, but i know some employees do not have manager_id, for these employees without manager_id (null) i want the result to display “pip” while for the rest it displays original info. Answer The code you want is probably: Or more simply: The two significant issues…

t-SQL cartesian production of several tables

I would like to get a cartesian product of several tables in SQL (which are actually only one column, so no common key). For example: I tried CROSS JOIN, but I couldn’t find an example with multiple tables. Is the only way to do it is nesting? What if we have 15 tables to join that way… it creates…

Insert into select SQL with windowsForm

I want to insert some data in Table1 in my database selecting it from another Table2 but the Table1 has another attribute for username (ComputerName). What I have tried: Answer I think you are looking for something like this :

what this sign mean in sql query

i have the following code : What is /*_archive*/ mean ? in my database we have : Answer From a /* sequence to the following */ sequence, as in the C programming language. This syntax enables a comment to extend over multiple lines because the beginning and closing sequences need not be on the same line. MySQL…

select random COLUMN from PostgeSQL

I have a table which contains some links to photos in a few columns and I need to get a random photo from it. gives me a 3 links. But can I get only 1 random out of it? Answer You can unpivot. For instance: If the columns can ever be NULL, then you might want WHERE v.photo IS NOT

Convert day of year & year to date Big Query

I have some data which instead of having a date field, contains the day of the year as a number and the year as a number in different columns. I have tried using big query functionality PARSE_DATE to achieve this by using PARSE_DATE(“%Y %j”, “2020 258”) but this does not work. When che…

Whats wrong with my query, should i use WHERE?

So, what am i doing wrong? This query: Will give me this error: Failed to run query: SQLSTATE[HY000]: General error: 1111 Invalid use of group function This query: Will give me this error: Failed to run query: SQLSTATE[42000]: Syntax error or access violation: 1064 You have an error in your SQL syntax; check …