• Shuffle
    Toggle On
    Toggle Off
  • Alphabetize
    Toggle On
    Toggle Off
  • Front First
    Toggle On
    Toggle Off
  • Both Sides
    Toggle On
    Toggle Off
  • Read
    Toggle On
    Toggle Off
Reading...
Front

Card Range To Study

through

image

Play button

image

Play button

image

Progress

1/16

Click to flip

Use LEFT and RIGHT arrow keys to navigate between flashcards;

Use UP and DOWN arrow keys to flip the card;

H to show hint;

A reads text to speech;

16 Cards in this Set

  • Front
  • Back

Default order for order by clause

asc.

order by column number

select username,email from Users order by 1 desc




will order the results by username desc

select expressions + order by

select name, price*quantity 'total price' from sales order by 'total price' desc




select name, price*quantity 'total price' from sales order by [total price] desc




select name, price*quantity 'total price' from sales order by price*quantity desc




select name, price*quantity 'total price' from sales order by 2 desc






group by - aggregate functions

sum,avg,count,max,min,round

User defined aggregate functions

-

group by - non-aggregate columns in select limitation

All non- aggregate columns in select must be included in the group by clause

having clause

The HAVING clause is used to filter the result set based on the result of an aggregate function. It is typically located near or at the end of the SQL statement.




HAVING is often coupled with the presence of the GROUP BY clause, although it is possible to have a HAVING clause without the GROUP BY clause.




SELECT Store_Name, SUM(Sales)FROM Store_InformationGROUP BY Store_NameHAVING SUM(Sales) > 1500;

sql alias

Alias refers to the practice of using a different temporary name to a database table or a column in a table.




SELECT "table_alias"."column_name1" "column_alias"FROM "table_name" "table_alias";

sql alias using 'as'

The keyword AS is used to assign an alias to the column or a table. It is inserted between the column name and the column alias or between the table name and the table alias.




SELECT "table_alias"."column_name1" AS "column_alias"FROM "table_name" AS "table_alias";

function to find the number os character in nvarchar

len

how to find last three characters in nvarchar

right(string,3)

how to round a float

round(float)

salary


1


2


1




What is avg(salary)?

1

Salary


1


2


1




How to get the accurate avg ?

avg(cast(salary as float))

What is the right way to print space separated integers

select cast(int1 as nvarchar(100))+' '+cast(int2 as nvarchar(100))

how to round a float to nearest integer

round(float,0)