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…
Tag: sql
how to join two hive tables with embedded array of struct and array on pyspark
I am trying to join two hive tables on databricks. tab1: The schema of “some_questions” “some_questions” example: tab2: I need to join tab1 and tab2 by “question_id” such that I get a new table I try to join them by pyspark. But, I am not sure how to decompose the array wit…
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 :
SQL: How to get salary format of “$99,999.00”
In my table, the salary is in format “99999”, how do I get it/select it into the format of “$99,999.00”? Answer You can use a format mask like the one below. Different format models can be found here.
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
How do you I calculate the difference between two timestamps in PostgreSQL?
I have a SELECT query to retrieve data I need. One of the needed data is a an “aggregate” function to select two timestamp dates and calculate the difference between them. Using several resources and websites, they all gave me save answer and it did not work: I’m getting an error on the R…
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 …