procedures cannot have the same name in SQL)
@str nvarchar( -)
as
Print @str
Go
execUp_printexecUp_print1'Oh, hello.'
--stored procedure with output parameters
Create procedureUp_print2@xing nvarchar(1),
@ming nvarchar(5),
@rtn nvarchar(6) Output as
Set @rtn=@xing+@ming
Go
Declare @rtn nvarchar(6)
execUp_print2'Li','Tao',@rtnOutputPrint @rtn
----Write a new student's deposit process Up_insertstu
if(object_id('Up_insertstu','P')) is not NULL
The operation of the Aggregate function targets a series of values and returns a single value. Note: If a SELECT statement is used in many other expressions in the list of items in the SELECT statement, the select must use the GROUP by statement! First, all SQL instances are used to the following table
o_id
OrderDate
Orderprice
Customer
1
2008/12/29
10
Document directory
(1) No parameter form
(2) Parameters
(1) No parameter form
(2) Parameters
(1) No parameter form
(2) Parameters
(1) No parameter form
(2) Parameters
(1) No parameter form
(2) Parameters
This article describes the use of the five Aggregate functions, namely Count, Sum, Min, Max, and Avg. These functions are used in the same scenario
the day of the year,DW represents the day of the week and returns an integer default of 1 for SundayGETDATE No parametersSelect GETDATE ()Back to 2009-04-28 18:57:24.153Returns the current system date and time.DayDateSelect Day (' 2007-12-11 ') returns 11Returns an Integer that represents the part of the day of the specified date.Equivalent toDATEPART (dd, date)MonthDateSelect month (' 2007-12-11 ') returns 12Returns an Integer that represents the part of the month of the specified date.Equival
the day of the year,DW represents the day of the week and returns an integer default of 1 for SundayGETDATE No parametersSelect GETDATE ()Back to 2009-04-28 18:57:24.153Returns the current system date and time.DayDateSelect Day (' 2007-12-11 ') returns 11Returns an Integer that represents the part of the day of the specified date.Equivalent toDATEPART (dd, date)MonthDateSelect month (' 2007-12-11 ') returns 12Returns an Integer that represents the part of the month of the specified date.Equival
Stored Procedures, functions, and trigger code in SQL Server are stored in SYS. SQL _modules.
Return a line for each module object defined in the SQL language. Objects of the P, RF, V, TR, FN, if, TF, and r types are associated with SQL
sorted data, so its ranking is 4 + 1 = 5
To sum it up, over defines a set of rows that is a function that returns a unique value each time it is returned to the current row. In this example, the Rank function is used to return a ranking of the current row.
Other functions used in the over-over collocation
Aggregate functions-SUM, COUNT, MIN, MAX
Rank functio
SQL Server Functions
-- Aggregate functionsUse pubsGoSelect AVG (distinct price) -- calculate the averageFrom titlesWhere type = 'business'
Use pubsGoSelect max (ytd_sales) -- maximum numberFrom titles
Use pubsGoSelect min (ytd_sales) -- Minimum NumberFrom titles
Use pubsGoSelect Type, sum (price), sum (advance) -- sum
Tags: result create Word field SSID simple int customer regWhen using SQL SERVER database, functions should be used, such as the system aggregate function Sum (), Max () and so on. But when some beginners write custom functions, they often ask what a table-valued function is
: Reduce similar data in a group
The biggest difference between classification and grouping is that categorical data displays all records (within any qualifying criteria), while grouped data does not display these records. The GROUP by clause reduces similar data in one record. For example, GROUP by can return a unique list of postal codes from the source file that duplicates those values:
SELECT ZIP
From Customers
GROUP by ZIP
Include only those columns in the group by and select column lists.
that can be used in addition to group by? The Niang the result also really has, over (partition by) function, then it and peacetime uses group by have what difference? Group BY In addition to the results of a simple grouping, and commonly used with aggregate functions, Partition by also has a grouping function, belongs to the Oracle analysis function, here is not detailed no no, no.
Look at the code:
O
CWHERE=1 3. PagingReturns the number of rows in the result set, starting with 1 for each partition, and order by to determine the order in which the rows are assigned unique row_number in a particular partition.Four, ranking function 1, Row_number ()Returns the number of rows in the result set, each of which is calculated from 1, and order by determines the order in which the rows are assigned unique row_number in a particular partition. SELECT Over by ORDER by Createtime), score, Nam
function associates the rows in the result to a group and assigns each row the number of the group to which it belongs, starting with the number 1. For each row, NTILE returns the number of the group to which this row belongs. If the number of rows in a partition cannot be integer_expression (that is, the passed-in parameter, which means that the meaning of several groups) is divisible, then one member will have two groups of different sizes. Larger groups precede smaller groups in the order s
Tags: research trace title ORM CSDN SQL Server Design example data Transferred from: Leo_wlcnblogsSQL Server functions explained by some common DLLsIf your SQL Server is installed in the C drive, the following path is the storage
This section adds a large number of sqlserver functions to an article, from simple SQL query functions, character processing functions, stored procedure functions, statistics, and character truncation functions, date
TimeStandard Time for mst mdt Mountainous AreasNST standard time for new FinlandPst PDT Pacific Standard TimeYst ydt Yukon Standard Time
Character functions supported by Oracle and Their Microsoft SQL Server equivalent functions:
Functions: Oracle Microsoft
T-SQL language provides us with a more flexible way to manipulate data, that is, functions, functions are divided into three main categories: scalar function: (pass in a parameter, and then a parameter) aggregate function (pass in multiple parameters, outgoing one parameter), table-valued function (passing in a result
() month () --No seconds Day () Select year (' 1999-1-1 ') Select Month (GetDate ()) Determine if the date is correct isdate () Select IsDate (' 2000-2-31 ') ----return bit type , False is 0,true is 1 Add Time DateAdd (A, B, D)----a add what type (year,month,day) B plus how many C to who add Select DATEADD (year,5, ' 2000-1-1 ') Returns the day of the Week Datename (weekday, time)-The returned value is the same as the string datepart can return a few weeks, but the type of int is returned Se
Tags: number start default starting point how many XXX aggregate numeric parameter descriptionString functionsIn developing T-SQL, it is often necessary to perform a variety of operations on strings, and the following describes commonly used string functions. 1. ASCII ASCII code to get characters The ASCII code is the standard encoding of the character. To get
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.