I have a table with column name date of type timestamp I’m trying to delete old rows with the following query: delete from my_table where date<(now()-'30 days'::interval) but all rows are deleted. …
Tag: where-clause
I need some help in a query in SQL Server [closed]
I need a query that filters from the first day of the previous month and the current day at 0 hours. Can anyone help me?
SQL Query – How to apply different conditions (Where clause?) to specific aggregated columns
I have a table (simplified example below) consisting of TEST(s), TESTPRICE per test and TESTSTATUS. I would like to be able to run a query that will result in two aggregated columns, one for pending …
How to filter record in a table with different condition
How to find the record in a table which as only ‘Return’ as Reason? I have table which has many records As per the data in the table, it returns only records with policy number 5555, because only that policy number has only ‘Return’; all other policy numbers have both ‘Return’ and ‘Success’ which I don’t need. Kindly help me.
Something wrong with this SQL query?
Is there something wrong with this query? SELECT id, ( 6371 * acos(cos(radians(?1)) * cos(radians(latitud)) * cos(radians(longitud) – radians(?2)) + sin(radians(?1)) * sin(radians(latitud)))) …
how do we check if an element in the array exists and if it has a value of “true” in Presto
The data in the array looks like XXXX:”False”. I used element_at(array_name,’Field’) and contains(map_keys(array_name),’Field’). They only check if the element is present in the array. But if the ‘Field’ has a value of ‘true’, How do i check that value? Answer Assuming that you have a map at hand, and that you want to check the value of of a given
Select last N rows with multiple values in a single query
I have a table: messages: < id – title – body – city – street – building – created on > While I was able to select required messages in multiple queries, I need to do it in a single one: Here are my queries at the moment: I need one query because I can then use ORDER BY id
SQL query with having function to only includes parts of another column?
I am trying to find fact_order_id’s that have beverage only items. This would make the fact_order_id not include any food items. I have used 2 separate SQL Queries below. When I go back and check my work, I notice some fact_order_id’s in the output aren’t beverage only orders. Here are the 2 separate SQL Queries that give me the same
SQL how to obtain two columns as a result of a two where condition in one statement
I’m enrolling in a Coursera course called SQL FOR DATA SCIENCE, offered by the University of California, Davis. I’m doing the last test and there is the next question based on a table of customer …
Sql query to select several items from a another table in relation to values on a single row of a table
These are my two tables, wish do a mysql query to return: id_order,qty,id_user as name1 and updatedby as name2. I’ve tried this query but not working: Answer Use this. See the demo here: DB-Fiddle