Clauses ¿What can we do with them? Depending on what clause we’re going to use, we can do different things, there are five clauses that we can use: From We use it to set the table where a field comes from  Where It is used to set criteria or conditions for rows, it is like a filter for rows .png) Group By It can group rows by a field Having It is used to set criteria or conditions for a group of rows, it is like a filter for grouped rows. Order by It can order rows by a field, by default, all the rows are ordered by the first field.  As you can see in the picture the rows are ordered by the fecha field, by default the clause “order by” will order the rows of text type from a to z, the rows of date type from the oldest year to the youngest year, and the rows of number type from 0 to latest number if we want to change this order we can use the “desc” instruction. ¿When to use it? After we use a command and when we want to query for more specific information and also there is an order to follow when we use clauses the order is command + from + where + group by + having + order by, there is no need to use all the clauses it depends in what we want to query Operators After using clauses we can use operators, operators are used to set a more specific query. There are two types of operators, the logical operators, and the comparison operators. Logical Operators And It can concatenate criterias  Or It can concatenate instructions with the same criteria  Not Not logic Comparison Operators Greater than '> Less than < Greater than or equal to ≥ Less than or equal to ≤ Equal to = Not equal to <> Between It is used to set a range of conditions  As you can see if we want to use “between ”also we have to use the “and” operator. Like Used with wildcard characters In Used to specifying rows in a determinate field. Grouped queries or total queries ¿What is a grouped query? It is a query where we get a total result of rows that are grouped. ¿When to do a grouped query? When we want a total result of rows that are grouped like for example… A query where we need to know the total of persons of a field or the max value of a field of values. ¿How to do a grouped query? We need functions and fields, we need two fields, one field is going to be the field where rows are going to be grouped and the other field is going to be the field where we’re going to get the totals, so a field for rows and other for totals. Alias and names inside a query What is an alias? It is a way in how we can change the name of a column in a query, I said query because just we are changing the name inside a query if we change the name of a field inside a query that doesn’t affect the original column’s name if we have an alias inside a query we need to use the alias and not the original name. Aggregation functions We have functions called aggregation functions that are used to make grouped queries, aggregation functions are: AVG We used it to get the average of a field.  Count We used it to count the number of rows in a field. Sum We used it to sum the rows of a field. Max We used it to get the max of rows of a field. Min We used it to get the min of rows of a field. Extra important information Where clause select rows to display before they been grouped for an aggregation function while having clause select rows to display after they been grouped for an aggregation function. When we use the aggregation functions we use the having clause, also we can use the where clause but there is no logic in use it, because “where” is used for setting criteria for rows that are not inside a group, instead of using “where” in a query where we have aggregation functions, we can use “having” that is used for setting criteria for rows that are inside a group. 
author | darienken |
---|---|
permlink | clauses-operators-and-functions-in-sql |
category | sql |
json_metadata | "{"tags":["sql","mysql","programming","database","engineering"],"image":["https://images.hive.blog/DQmbMD16xhdMZTFRvTFdMwQSfsHixfEAJs3eGqNprBFSime/1_3kNCAsOFnUNZ2FzqtlG-ig.png","https://images.hive.blog/DQmbMD16xhdMZTFRvTFdMwQSfsHixfEAJs3eGqNprBFSime/1_3kNCAsOFnUNZ2FzqtlG-ig%20(1).png","https://images.hive.blog/DQmNr4cBYQ4w4Rx3Yk8ZX4sEy1NwVEU4SXcVWSd84Luzqjq/1_Y9efaolkxg6JXXE4Mz3AjQ.png","https://images.hive.blog/DQmRxUhJaBDC68thmYm7ErfwLy16fiLmT4q23BEj5VUAcgp/1_fQQkExEHRbxKRC7iaX3NyA.png","https://images.hive.blog/DQmbL3eHhS6Txmu7oMkxutYCCXra3pWa7gB8G5bjK1U4smS/1_ZxYmfqL55HHb9VUHrsk4pg.png","https://images.hive.blog/DQmUX34JhQsYAH444CXZu3eUC2H39E2DeVNdBFXzNodX4sX/1_c5depa1H214GI4l2EXmFkg.png","https://images.hive.blog/DQmWyJHh8XFwZQ2qB5kLrGc15xQ8aipLVGgSxdc1dPgrRtE/1_APg_EHUznxLgCJuElR-gew.png","https://images.hive.blog/DQmfVGYzmfXi3Hp6TiqouZuUCJzcZ4wgrBRhJgmsmaFhFWF/1_ruy7RV2J5AwMwp3GfSKzWw.png"],"app":"hiveblog/0.1","format":"markdown","description":"Clauses, operators, and functions in SQL. Clauses ¿What can we do with them? Depending on what clause we’re going to use..."}" |
created | 2021-10-02 04:21:30 |
last_update | 2021-10-02 04:21:30 |
depth | 0 |
children | 1 |
last_payout | 2021-10-09 04:21:30 |
cashout_time | 1969-12-31 23:59:59 |
total_payout_value | 0.317 HBD |
curator_payout_value | 0.303 HBD |
pending_payout_value | 0.000 HBD |
promoted | 0.000 HBD |
body_length | 4,876 |
author_reputation | 7,051,097,276 |
root_title | "Clauses, operators, and functions in SQL" |
beneficiaries | [] |
max_accepted_payout | 1,000,000.000 HBD |
percent_hbd | 10,000 |
post_id | 106,714,398 |
net_rshares | 500,200,062,400 |
author_curate_reward | "" |
voter | weight | wgt% | rshares | pct | time |
---|---|---|---|---|---|
arcange | 0 | 123,631,710,562 | 2% | ||
raphaelle | 0 | 1,182,666,918 | 2% | ||
toolbox | 0 | 0 | 2% | ||
slider2990 | 0 | 2,235,285,885 | 30% | ||
walterjay | 0 | 6,178,225,913 | 0.35% | ||
felt.buzz | 0 | 3,133,711,971 | 0.35% | ||
fatman | 0 | 7,245,263,544 | 2% | ||
tonimontana | 0 | 5,391,287,155 | 100% | ||
cleanplanet | 0 | 3,611,531,543 | 0.35% | ||
pboulet | 0 | 702,469,228 | 0.7% | ||
ctime | 0 | 209,926,469,109 | 3% | ||
limka | 0 | 62,380,946 | 78.59% | ||
stemgeeks | 0 | 63,020,089,634 | 60% | ||
stemcuration | 0 | 1,178,617,561 | 60% | ||
babytarazkp | 0 | 4,625,950,058 | 40% | ||
abh12345.stem | 0 | 3,091,996,581 | 100% | ||
yggdrasil.laguna | 0 | 127,207,998 | 30% | ||
stuntman.mike | 0 | 6,720,611,375 | 30% | ||
fengchao | 0 | 4,018,721,556 | 2% | ||
laruche | 0 | 28,344,583,993 | 0.7% | ||
hive-143869 | 0 | 1,268,987,105 | 0.7% | ||
heystack | 0 | 1,753,459,036 | 100% | ||
dorkpower | 0 | 2,852,467,479 | 100% | ||
stemcur | 0 | 717,737,573 | 100% | ||
brofund-stem | 0 | 1,068,526,622 | 30% | ||
stemline | 0 | 3,723,528,738 | 30% | ||
meestemboom | 0 | 1,010,654,938 | 50% | ||
academiccuration | 0 | 705,782,580 | 100% | ||
emrebeyler.stem | 0 | 1,483,171,224 | 100% | ||
scooter77.stem | 0 | 612,251,591 | 60% | ||
krishu.stem | 0 | 673,846,968 | 100% | ||
ruari | 0 | 550,104,041 | 100% | ||
eturnerx-dbuzz | 0 | 5,467,135,433 | 10.7% | ||
adamada.stem | 0 | 744,952,077 | 100% | ||
juecoree.stem | 0 | 631,407,873 | 100% | ||
holovision.stem | 0 | 120,265,765 | 50% | ||
star.stem | 0 | 1,718,736,181 | 50% | ||
solominer.stem | 0 | 668,265,646 | 100% |
Congratulations @darienken! You have completed the following achievement on the Hive blockchain and have been rewarded with new badge(s) : <table><tr><td><img src="https://images.hive.blog/60x70/http://hivebuzz.me/@darienken/upvoted.png?202110020728"></td><td>You received more than 10 upvotes.<br>Your next target is to reach 50 upvotes.</td></tr> </table> <sub>_You can view your badges on [your board](https://hivebuzz.me/@darienken) and compare yourself to others in the [Ranking](https://hivebuzz.me/ranking)_</sub> <sub>_If you no longer want to receive notifications, reply to this comment with the word_ `STOP`</sub> **Check out the last post from @hivebuzz:** <table><tr><td><a href="/hivebuzz/@hivebuzz/pum-202109-final"><img src="https://images.hive.blog/64x128/https://i.imgur.com/lpF7k06.png"></a></td><td><a href="/hivebuzz/@hivebuzz/pum-202109-final">Hive Power Up Month Challenge - Winners List</a></td></tr><tr><td><a href="/hivebuzz/@hivebuzz/pum-202109-29"><img src="https://images.hive.blog/64x128/https://i.imgur.com/rv2OQ5F.png"></a></td><td><a href="/hivebuzz/@hivebuzz/pum-202109-29">Hive Power Up Month - Feedback from Day 29</a></td></tr><tr><td><a href="/hivebuzz/@hivebuzz/pud-202110"><img src="https://images.hive.blog/64x128/https://i.imgur.com/805FIIt.jpg"></a></td><td><a href="/hivebuzz/@hivebuzz/pud-202110">Hive Power Up Day - October 1st 2021 - Hive Power Delegation</a></td></tr></table>
author | hivebuzz |
---|---|
permlink | hivebuzz-notify-darienken-20211002t074128 |
category | sql |
json_metadata | {"image":["http://hivebuzz.me/notify.t6.png"]} |
created | 2021-10-02 07:41:27 |
last_update | 2021-10-02 07:41:27 |
depth | 1 |
children | 0 |
last_payout | 2021-10-09 07:41:27 |
cashout_time | 1969-12-31 23:59:59 |
total_payout_value | 0.000 HBD |
curator_payout_value | 0.000 HBD |
pending_payout_value | 0.000 HBD |
promoted | 0.000 HBD |
body_length | 1,429 |
author_reputation | 370,687,705,918,137 |
root_title | "Clauses, operators, and functions in SQL" |
beneficiaries | [] |
max_accepted_payout | 1,000,000.000 HBD |
percent_hbd | 10,000 |
post_id | 106,717,019 |
net_rshares | 0 |