Skip to content
Advertisement

Tag: sql

SQL select from Table1 that has no value in Table2

I have two tables with the following data: Table 1: Table 2: Then I used a join for this Table 3: I need to get the row with 101 – 204 – A and 102 – 213 – A. Data is available in Table 1 but has no data aligned in Table 2. Is there a way to get this?

Get rows within current month

Get the rows from a table filtered by current month in psql. Example table – After query result, assuming current month is July, 2020: Answer The usual approach is to use a range query to allow for an index usage on registration_date

SQL sum values in columns for each row

I have the following table: how do I sum the values of say, column 2 and 3, to return the sum? The expected result is: Answer You can do maths within a select statement, so the following will work:

additional condition in a SQL query with min(Date)

I have the code presented below provided to me by one of the members but I do not understand how it acts: The code extracts the min of start from another table. I wanna add an aditional condition like: I cannot insert the condition without an error. Also, I need only to see min(pr.”AsigStart”) from the pr table not all

SQL query to get the output

I have two tables Table A and Table B as listed below. What is the SQL query to get the below output? Answer This looks like a cross join, to generate all possible combinations of rows between the two tables. Assuming a structure like tablea(col), tableb(col): If you want to concatenate the results in a singe column:

sql; concatenate MIN(price) and MAX(price) into column?

I am working on an aws athena query like so: Which will give results like so: Right now I have maxprice and minprice as two separate columns, but I want to combine them into one column “price range” which will have minprice and maxprice separated by a ” – ” string, so it would look something like this: I tried

Window functions in SQL: why are they called window functions?

I understand window function but don’t understand why they are called window functions. When we say the “window” is it both the partition and the order by clauses? Answer Window functions operate on a range of rows, defined by the OVER clause. It is like you are looking through the window, you see sky, star, moon. You are not seeing

Advertisement