SQL ฟังก์ชัน

এসকিউএল-এ, গণনা এবং গণনা করার জন্য ব্যবহার্য বৈধ ফাংশন অনেক রয়েছে

ফাংশনের সংজ্ঞান

এসকিউএল-এর বৈধ ফাংশন সংজ্ঞান হল:

SELECT function(কলা) FROM টেবিল

ফাংশনের ধরন

এসকিউএল-এ, মৌলিক ফাংশনের ধরন এবং বিভিন্ন ধরনের সংখ্যা কিছুটা রয়েছে। ফাংশনের মৌলিক ধরন হল:

  • সমষ্টি ফাংশন
  • Scalar function

সমষ্টি ফাংশন (Aggregate functions)

সমষ্টি ফাংশনের কার্যক্রম একসারি মূল্যগুলির প্রতি প্রয়োগ করে একটি একক মূল্য ফেরার

মন্তব্য:SELECT বিবর্ণনের প্রক্রিয়ায় অন্যান্য বিভিন্ন প্রক্রিয়াকে ব্যবহার করছেন তবে, SELECT-এর GROUP BY বিবর্ণন বাধ্যতামূলক!

"Persons" টেবিল (অধিকাংশ উদাহরণে ব্যবহৃত)

নাম বয়স
Adams, John 38
Bush, George 33
Carter, Thomas 28

MS Access-এর সমষ্টি ফাংশন

Function Description
AVG(column) নিউল বাদে কোন কলার গড়মান ফেরার
COUNT(column) নিউল বাদে কোন কলার রেকর্ড সংখ্যা ফেরার
COUNT(*) প্রতিটি বিভিন্ন রেকর্ড গণনা করুন
FIRST(column) নির্দিষ্ট ক্ষেত্রের প্রথম রেকর্ডের মূল্য ফেরার
LAST(column) নির্দিষ্ট ক্ষেত্রের শেষ রেকর্ডের মূল্য ফেরার
MAX(column) Return the maximum value of a column
MIN(column) Return the minimum value of a column
STDEV(column)  
STDEVP(column)  
SUM(column) Return the sum of a column
VAR(column)  
VARP(column)  

SQL Server-এর সমষ্টি ফাংশন

Function Description
AVG(column) নিউল বাদে কোন কলার গড়মান ফেরার
BINARY_CHECKSUM  
CHECKSUM  
CHECKSUM_AGG  
COUNT(column) নিউল বাদে কোন কলার রেকর্ড সংখ্যা ফেরার
COUNT(*) প্রতিটি বিভিন্ন রেকর্ড গণনা করুন
COUNT(DISTINCT column) Return the number of distinct results
FIRST(column) Return the value of the first record in the specified field (not supported by SQLServer2000)
LAST(column) Return the value of the last record in the specified field (not supported by SQLServer2000)
MAX(column) Return the maximum value of a column
MIN(column) Return the minimum value of a column
STDEV(column)  
STDEVP(column)  
SUM(column) Return the sum of a column
VAR(column)  
VARP(column)  

Scalar function

Scalar functions operate on a single value and return a single value based on the input value.

Scalar functions in MS Access

Function Description
UCASE(c) Convert a field to uppercase
LCASE(c) Convert a field to lowercase
MID(c,start[,end]) Extract characters from a text field
LEN(c) Return the length of a text field
INSTR(c,char) Return the numeric position of a specified character in a text field
LEFT(c,number_of_char) Return the left part of a requested text field
RIGHT(c,number_of_char) Return the right part of a requested text field
ROUND(c,decimals) Round a number field to a specified number of decimal places
MOD(x,y) Return the remainder of the division operation
NOW() Return the current system date
FORMAT(c,format) Change the display style of a field
DATEDIFF(d,date1,date2) Used for date calculations