Calculations to be performed on multiple rows can be done using aggregate functions.
The functions available are as follows:
COUNT(): count the number of rows… 247 more words
The SQL standard knows a lesser known feature called GROUPING SETS. One particular side-effect of that feature is that we can group by “nothing” in SQL. 592 more words
It’s not entirely uncommon to want to group by a computed expression in an aggregation query. The trouble is, whenever you group by a computed expression, SQL Server considers the ordering of the data to be lost, and this will turn your buttery-smooth Stream Aggregate operation into a Hash Match (aggregate) or create a corrective Sort operation, both of which are… 1,206 more words
Simple Query to find the Specific character from a string.
Let us consider, a String ‘thisisagoodplace’ and want to find the count of ‘a’ in the string this below query will work. 30 more words
CREATE TABLE EMPLOYEE (EMP_ID NUMBER GENERATED ALWAYS AS IDENTITY, NAME VARCHAR2(50) NOT NULL, DATE_OF_BIRTH DATE NOT NULL, DESIGNATION VARCHAR2(50) NOT NULL, DATE_OF_JOINING DATE, DATE_OF_RESIGNATION DATE, LAST_WORKING_DAY DATE, CONSTRAINT EMPLOYEE_PK PRIMARY KEY(EMP_ID)); CREATE TABLE EMPLOYEE_SALARY(EMP_ID NUMBER NOT NULL, MONTH NUMBER(2) NOT NULL, YEAR NUMBER(4) NOT NULL, GROSS_EARNINGS NUMBER(10,2) NOT NULL, DEDUCTIONS NUMBER(10,2) DEFAULT 0 ON NULL, NET_SALARY AS (TOTAL_EARNINGS - TOTAL_DEDUCTIONS), CONSTRAINT EMPLOYEE_SALARY_PK PRIMARY KEY (EMP_ID), CONSTRAINT EMPLOYEE_SALARY_FK1 FOREIGN KEY (EMP_ID) REFERENCES EMPLOYEE(EMP_ID)); 610 more words