Skip to content

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”) fro…

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…