Skip to content

Tag: sql

Oracle SQL – implement logic based on CASE expression result

I have following query which returns me of percentage of rows with at least one NULL in any of columns: Query works fine to me and I am getting valid result. But I need to do further action in tablec, based on percentage calculated in my SELECT statement. If percentage of rows with NULL is below 30% I need to

SQL UPDATE base on COUNT

I have two tables product-table with fields (id, category_id) category-table with fields (id, num_of_products) The product table contains multiple products in different categories. And I know how to count product in each categories using But how do I update category.num_of_product using a single sql query wit…

Ajax request from PHP don’t return me an Array

I’m trying to return an array from a PHP script in Ajax, however, it seems to not work, it returns me a string rather an Array. I’m using CodeIgniter Framework, there is my .php code : And there is my Ajax request : My getAll() function just select all from the database, however i’m only usi…

Use one of two dates in where clause

I need to delete all records in a table where the CreatedDate or ModifiedDate is greater than x. The logic is as follows: If ModifiedDate is not null then use this value Otherwise use the CreatedDate value Not applying the if/else statement correctly. Answer Use this where clause: