Congratulations to all the winners of April 2013, they have won INR 3400 cash and INR 20147 worth prizes !
DotNetFunda.Com Logo
Twitter TwitterLinkedIn
YouTubeGoogle
 Online : 34088 |  Welcome, Guest!   Register  Login
 Home > Code Snippets > SQL Server > Use of compute clause ...
Rajni.Shekhar

Use of compute clause

 Code Snippet posted by: Rajni.Shekhar | Posted on: 4/18/2012 | Category: SQL Server Codes | Views: 337 | Status: [Member] | Points: 40 | Alert Moderator   


---CREATE TABLE

CREATE TABLE STUDENT (Student_ID INT NOT NULL IDENTITY,
Student_Name CHAR(50) NOT NULL,
Marks FLOAT NULL)

----INSERT VALUES IN TABLE
insert into STUDENT values ('STUDENT1', 50)
insert into STUDENT values ('STUDENT2', 40)
insert into STUDENT values ('STUDENT3', 20)
insert into STUDENT values ('STUDENT4', 80)
insert into STUDENT values ('STUDENT5', 90)

---GET MAX MARKS USING COMPUTE CLAUSE
SELECT * FROM STUDENT COMPUTE MAX(MARKS)

---GET SUM OF MARKS USING COMPUTE CLAUSE
SELECT * FROM STUDENT COMPUTE SUM(MARKS)



Thanks,
Rajni Shekhar
Found interesting? Add this to:


>> Write Response - Respond to this post and get points

More codes snippets

About Us | Contact Us | The Team | Advertise | Software Development | Write for us | Testimonials | Privacy Policy | Terms of Use | Link Exchange | Members | Go Top
General Notice: If you find plagiarised (copied) contents on this page, please let us know the original source along with your correct email id (to communicate) for further action.
Copyright © DotNetFunda.Com. All Rights Reserved. Copying or mimicking the site design and layout is prohibited. Logos, company names used here if any are only for reference purposes and they may be respective owner's right or trademarks. | 5/20/2013 4:58:10 AM