Learn how to use a common table expression or CTE in SQL, and read how recursive CTEs turn impossible Postgres queries into possible.
Indexes. They're one of the most powerful and misunderstood aspects of SQL performance. In this post we'll look at the purpose of an index, how to create and choose choose your index type. Then finish with a discussion of how to decide what to index and
--PRINT @DB +',' + @LogFile SELECT@SQL ='EXEC sp_dbOption ['+ @DB +'], ''trunc. log on chkpt.'', ''True''' EXEC(@SQL) SELECT@SQL ='USE ['+ @DB +'] DBCC SHRINKFILE('''+ @LogFile +''',''truncateonly'') WITH NO_INFOMSGS' EXEC(@SQL) SELECT@SQL ='EXEC sp_dbOption ...
Up to 254 additional arguments.Back to top3. Things to knowThe SUMPRODUCT function is one of the most powerful functions in Excel and is one that I often use. I highly recommend learning how it works.The SUMPRODUCT function requires you to enter it as a regular formula, not an array ...
To group rows into part of a datetime value withOracle SQLyou can use thetruncfunction. This rounds down datetime values. The first argument is the datetime and the second is the units to round down to. For example, this groups the rows by hour: ...
group by date_trunc('month', created_at); With our basic data in hand, we want to implement the above formula in SQL. To keep things clear, we wrap each step of the calculation separately: Calculate the conversation rate, p. Using p, calculate the standard error, se. ...
Learn how to use SQL to calculate customer lifetime value in Metabase.In our primer on customer lifetime value, we discussed where some companies go wrong with the metric and offered some guidance on putting LTV to use. This guide takes a more hands-on approach: we’ll tackle exactly how...
Our business use case requires us to call theDATE_TRUNCPostgreSQL function like this: SELECT p.title AS col_0_0_, date_trunc( 'day', (p.created_on AT TIME ZONE ?) ) AS col_1_0_ FROM post p WHERE p.id = ? As explained inthis article, before using a SQL function in the SELEC...
4. Query to get the First and Last Date of the Current Year in Oracle DatabaseSELECT TRUNC(SYSDATE, 'YYYY') AS first_date_of_year FROM dual;SELECT LAST_DAY(TO_DATE('31-12-' || TO_CHAR(SYSDATE, 'YYYY'), 'DD-MM-YYYY')) AS last_date_of_year FROM dual;These queries are used ...
There are two ways to do this in Tableau :If you CAN USE sql AND YOU actually need the ...