SELECT teamname, COUNT(teamid) FROM eteam JOIN goal ON id=teamid GROUP BY teamname;10、 Show the stadium and the number of goals scored in each stadium.select stadium,count(gtime) from game join goal on (game.id=matchid)group by stadium11、 For every match involving 'POL', show the...
SELECT SUM(population) FROM world 2) List all the continents - just once each. select distinct continent from world distinct: 去重 3) Give the total GDP of Africa select sum(gdp) from world where continent = 'Africa' 4) How many countries have anareaof at least 1000000 select count(name)...
You can useSELECTwith theORDERBYclause to retrieve and display rows from a table ordered (sorted) by a specified column in the table. The specified column in theORDERBYclause does not have to be in theSELECTlist of columns that you want to display. You can specify the sort order asASCfo...
To order results in descending order, you can put the keyword DESC after your ORDER BY. For example, to get all the names in the people table, in reverse alphabetical order: SELECT imdb_score,film_id FROM reviews ORDER BY imdb_score DESC; Sorting multiple columns ORDER BY can also be us...
The SQL statement names that appear as the title to each statement description in this chapter are listed in alphabetical order. For some statements, important details of the semantics appear in other volumes of this documentation set, as indicated by cross-references. For many statements, the ...
* * Note that sort clauses cannot be included at this level --- SQL requires * SELECT foo UNION SELECT bar ORDER BY baz * to be parsed as * (SELECT foo UNION SELECT bar) ORDER BY baz * not * SELECT foo UNION (SELECT bar ORDER BY baz) * Likewise for WITH, FOR UPDATE and ...
SELECT ENAME FROM emp2019284073 WHERE deptno = 10 AND job = (SELECT job FROM dept2019284073 WHERE dname = 'SALES'); Find the employees located in Liverpool who have the same job as Allen. Return the results in alphabetical order by employee name. SELECT ename FROM emp2019284073 e, dept201...
You can mark one or both period columns with HIDDEN flag to implicitly hide these columns such that SELECT * FROM <table> doesn't return a value for those columns. By default, period columns aren't hidden. In order to be used, hidden columns must be explicitly included in all queries th...
SELECT RejectedQty, ((RejectedQty/OrderQty)*100) AS RejectionRate, ProductID, DueDate FROM Purchasing.PurchaseOrderDetail ORDER BY RejectedQty DESC, ProductID ASC; GO The following execution plan for this query shows that the query optimizer used a SORT operator to return the result ...
SELECT(LastName +','+SPACE(1) +SUBSTRING(FirstName,1,1) +'.')ASName, e.JobTitleFROMPerson.PersonASpJOINHumanResources.EmployeeASeONp.BusinessEntityID = e.BusinessEntityIDWHEREe.JobTitleLIKE'Vice%'ORDERBYLastNameASC; GO Here's the result set. ...