Solved

get username and the com1+com2 fields and then sum them for the entire user id in sql server

Posted on 2014-11-05
2
76 Views
Last Modified: 2014-11-11
get username and the com1+com2 fields and then sum them for the entire user id in sql server
0
Comment
Question by:cbrune
2 Comments
 
LVL 65

Expert Comment

by:Jim Horn
ID: 40425311
What's a 'com1+com2' fields?

SELECT SUSER_NAME() as login_name, USER_NAME() as user_name
0
 
LVL 47

Accepted Solution

by:
Vitor Montalvão earned 500 total points
ID: 40428561
It's hard to understand the question but I'll try to guess that you want a SUM of fields grouped by users:
SELECT id, name, SUM(com1+com2)
FROM TableNameHere
GROUP BY id, name

Open in new window

0

Featured Post

Comprehensive Backup Solutions for Microsoft

Acronis protects the complete Microsoft technology stack: Windows Server, Windows PC, laptop and Surface data; Microsoft business applications; Microsoft Hyper-V; Azure VMs; Microsoft Windows Server 2016; Microsoft Exchange 2016 and SQL Server 2016.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
SQL Server Generate Scripts Fails 5 36
How to share SSIS Package? 6 37
Query Help - MSSQL - Averages 5 27
SQL Server 2015 Restore - doing it right 2 14
JSON is being used more and more, besides XML, and you surely wanted to parse the data out into SQL instead of doing it in some Javascript. The below function in SQL Server can do the job for you, returning a quick table with the parsed data.
This article shows gives you an overview on SQL Server 2016 row level security. You will also get to know the usages of row-level-security and how it works
Using examples as well as descriptions, and references to Books Online, show the different Recovery Models available in SQL Server and explain, as well as show how full, differential and transaction log backups are performed
Viewers will learn how to use the UPDATE and DELETE statements to change or remove existing data from their tables. Make a table: Update a specific column given a specific row using the UPDATE statement: Remove a set of values using the DELETE s…

777 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question