SELECT t.*,GROUP_CONCAT( SELECT CONCAT(dl2.day,GROUP_CONCAT(dl2.location_id)) as concated FROM days_location dl2 WHERE therapist_id=85 GROUP BY dl2.day
SELECT COUNT(*)(SELECT DISTINCT a.my_id, a.last_name, a.first_name, b.temp_val. FROM Table_A a INNER JOIN Table_B b on a.a_id = b.a_id).
SELECT id, SUM(CASE WHEN status = 3 THEN 1 ELSE 0 END) as status_3_count FROM yourtable GROUP BY id. or just use a WHERE status = 3
Difference is in the field you select. When counting COUNT(*) NULL values are taken into account (count all rows returned).
I have the following query. select main_cat_name,cat_url from mf_main order by main_cat_name.
SELECT reltuples FROM pg_class WHERE relname = 'tbl'; Since this is just a single row this is blazing fast. Update: since 9.2 a new way to store the visibility information allowed index-only
select Count(*) as Num_Rows from SysObjects where Type = 'U' and Name = 'System_Configuration'.
Ниже приведен пример команды SELECT, где будет отображать все строки из таблицы “worker”.
SELECT FirstName, COUNT(*) FROM Person.Person GROUP BY FirstName. Посмотрел на план запроса и увидел там явно неадекватное значение Estimated
SELECT is used to retrieve rows selected from one or more tables, and can include UNION statements and subqueries.