Question : I need to query two huge tables (more than milion records). Besides other conditions, there is also a […]
Tag: where
Under what circumstances would these 3 queries return different number of results?
Question : Hello I have the following question: Query 1: SELECT b.id, ( SELECT SUM(cb.invoice_amount) AS sum […]
Postgres: strange long request: A is fast, B is fast, A WHERE IN B is slow
Question : There is a lot of rows in table “logs” (the Request A FROM). Request A is quick and […]
Using column alias in a WHERE clause doesn’t work
Question : Given a table users with two fields: id and email. select id, email as electronic_mail from ( select […]
How to use comma separated columns in CASE WHEN Statement?
Question : I am trying to add below CASE WHEN Statement in SQL WHERE Clause, But SQL Server not allowing […]
Order of WHERE IN result for PostgreSQL
Question : If I use the following selection SELECT * FROM users WHERE id IN (3,1,2) Can I expect the […]
Building where clause based upon parameters
Question : In PostgreSQL I am trying to build a where clause in a function that uses an inbound parameter […]
Effect of where statement in subquery (to get rid of unnecessary join)
Question : Please consider the following query: select * from parent p where p.id in ( select p.id from parent […]
UPDATE with too much values at IN state takes too long
Question : I have the next query: UPDATE plates_owners SET deleted=1 WHERE plate_id=4748 AND branch_id IN (23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,42,43,46,47,48,64,79,82,83,102,103,130,169,209,218,220,221,222,223,224,226,231,232) Here is my […]
Given a table with date_time column, how to run a query using only the date
Question : I have a DB with a table which has a column datetime Date_Time. The format of this is […]