Convert varbinary column to base64
SELECT Id, FileInBinary, --the varbinary value we want converted to base64 CAST('' AS XML).value('xs:base64Binary(sql:column("FileInBinary"))', 'varchar(max)') AS FileInBase64 FROM Files
COUNT(*)
COUNT(1)
COUNT(column_name)
Most database systems provide logs that record query execution times. These logs can be a valuable source of information to identify slow queries. You can configure logging levels and output formats according to your database system.
-- Enable slow query logging in MySQL SET GLOBAL slow_query_log = 'ON'; SET GLOBAL long_query_time = 1; -- Define the threshold (in seconds) for slow queries -- View slow query log SHOW VARIABLES LIKE 'slow_query_log%'; SHOW VARIABLES LIKE 'long_query_time'; SHOW VARIABLES LIKE 'slow_query_log_file';
This function returns the rank of each row within a result set partition, with no gaps in the ranking values. The rank of a specific row is one plus the number of distinct rank values that come before that specific row.
SELECT product_id, product_name, list_price, DENSE_RANK () OVER ( ORDER BY list_price DESC ) price_rank FROM production.products;