111

Sunday, 28 June 2020

using sql_query to count member of family?

Octavio Roylance: http://www.sql-tutorial.ru/en/book_getting_summari...

Everette Rovinsky: @Jan Dvorak - What you've observed isn't quite true. While your answer is absolutely right, @Martijn answer too is a correct one. Probably, he wrote it based on MS SQL Server syntax while yours is meant for different DBMS, perhaps MySQL or Oracle.MS SQL Server mandates the use Square Brackets to make a string eligible to be a column name. There are several other rules including this.Both of your solutions are valid. One has to include GROUP BY clause in their query to compute the count of records, in each category as mentioned in Group By with HAVING as optional.-- In 'thoughts'...Lonely Rogue....Show more

Jeremy Donohue: select [family name], count(*) as [number of family member]from tablegroup by [family name]

Charissa Riley: SELECT `family name`, COUNT(*) as `number of family member` /*SIC*/FROM $tableWHERE $row_condition /* which persons do you count */GROUP BY! `family name`HAVING $aggregate_condition /* which families do you want */Edit: Martin: the [...] syntax won't work. Arbitrary table and column names must be escaped by backticks....Show more

No comments:

Post a Comment