.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
Sign In
Win Surprise Gifts!!!

Top 5 Contributors of the Month
Gaurav Pal
Post New Web Links

combining two fields with a group by

Posted By:      Posted Date: October 19, 2010    Points: 0   Category :ASP.Net
declare @jax table
cus nvarchar(50),
sum int,
sumly int,
rep nvarchar(50)

insert into @jax (rep,cus,sum)
SELECT     TOP 10 dbo.tblTerritory.fldSalesRep,dbo.ExecSales.CUSTOMER_NAME, 
                      SUM(dbo.ExecSales.JAN_SLS_AMNT + dbo.ExecSales.FEB_SLS_AMNT + dbo.ExecSales.MAR_SLS_AMNT + dbo.ExecSales.APR_SLS_AMNT + dbo.ExecSales.MAY_SLS_AMNT
                       + dbo.ExecSales.JUN_SLS_AMNT + dbo.ExecSales.JUL_SLS_AMNT + dbo.ExecSales.AUG_SLS_AMNT + dbo.ExecSales.SEP_SLS_AMNT + dbo.ExecSales.OCT_SLS_AMNT
                       + dbo.ExecSales.NOV_SLS_AMNT + dbo.ExecSales.DEC_SLS_AMNT) AS sum
FROM         dbo.tblTerritory INNER JOIN
                      dbo.ExecSales ON dbo.tblTerritory.fldBranch = dbo.ExecSales.BRANCHID
WHERE     (dbo.tblTerritory.fldSalesRep = N'mbradshaw') AND (dbo.ExecSales.load_year = 2010)
GROUP BY dbo.ExecSales.load_year, dbo.tblTerritory.fldSalesRep, dbo.ExecSales.BRANCHID, dbo.ExecSales.CUSTOMER_NAME

insert into @jax (rep,sumly)
SELECT     TOP 10  dbo.tblTerritory.fldSalesRep,SUM(dbo.ExecSales.JAN_SLS_AMNT + dbo.ExecSales.FEB_SLS_AMNT + dbo.ExecSales.MAR_SLS_AMNT + dbo.ExecSales.APR_SLS_AMNT + dbo.ExecSales.MAY_SLS_AMNT
                       + dbo.ExecSales.JUN_SLS_AMNT + dbo.ExecSales.JUL_SLS_AMNT + dbo.ExecSales.AUG_SLS_AMNT + dbo.ExecSales.SEP_SLS_AMNT + dbo.ExecSales.OCT_SLS_AM

View Complete Post

More Related Resource Links

Delete spaces created by combining 2 fields


Howdy, this is kind of a continuation of an answer I got from this thread:  http://forums.asp.net/t/1592766.aspx

My users will enter a city/station where an incident occured, and the date.  The trigger below does work, but it will occasionally put spaces between the citystation and the date.  I think this happens when the citystaion name is not very long, but not sure.

(ex: city____08242010)

How can I make sure that if the incidentid is going to have spaces, that sql deletes those spaces?  I need the id to be space free.





TRIGGER [dbo].[tr_AddID1] ON [dbo].[tblIncidents] INSTEAD

Creating Dynamic Group Fields for a Crystal Report?

I have a VB.Net application which generates quite a few Crystal Reports. One report in particular has a Group Section. What I am trying to do with my VB.Net app is pass a value (a sql server column name used in the report). This value is represented by radio buttons. For example, the user may check either "ZipCode" or "State" or "Category" or "Type" or "Vendor". Each of these options represent a column in the database table used in the report. I simply want to be able to write the "SelectionFormula" using one of these options but not sure how to go about it. Thanks, Blake

Can't get Distinct work, when combining fields from inner joined tables

Hi to all.I have a users table, each user has a session and each session has multiple parameters.I would like to retrieve all params for a specific user and get the paramID from the params table and the date submitted from the sessions table.This is the linq to SQL query so far:var items = (from param in db.Params join session in db.Sessions on param.SessionID equals session.ID where userID.Equals(session.UserID) //userID is the function argument orderby session.DateSubmitted descending select new { ParamID = param.ID, DateSubmitted = session.DateSubmitted }).Distinct(); I have noticed that when the DateSubmitted is fetched, i have multiple instances of a param in the result set, meaning that the Distinct does not work as expected. If i remove it like this:var items = (from param in db.Params join session in db.Sessions on param.SessionID equals session.ID where userID.Equals(session.UserID) //userID is the fu

Hide a measure group in excel 2007 'Show Fields Related to'


Hi All,

I know that if a I want to hide a measure group to users I have to set the properties 'Visible' to false for all the measure of the measure group.

But when I open a connection to the cube with Excel 2007 I see again the measure group in the drop down list 'Show Fields Related to' in the 'Pivot Table Fields List'.

I don't see it in the measure group list when I choose 'All' in the 'Show Fields Related to', but i don't want to see it in the list 'Show Fields Related to' too.


How I can do to hide permanently the measure group?


Thank you all,


Restict access to page fields. How to show field value to members of certain group?


I have the fields that should be shown for members of one group. How to implement this behavior?

Also i need to restrict access to editing other field for all except of limited amount of persons. How to do this?


All these questions are related to Site Content Types and Page Layouts.

Show/Hide fields on InfoPath based on context User Group Membership

I am reading a book on SharePoint 2010 Development by Wrox and although it is a good book, the InfoPath section is limited. I am Googling to see if I can find anywhere where i can perhaps have this type of functionality to hide and show a specific field based on their Group Membership?
Victor Palma

how to have more than one group by clause and summation of data fields as well in group by footer!


How do we have more than one group by clause in SSRS  and summation of all fields in group by footer clause !

Is it possible to have nested group by clause in SSRS and summation of reports fields in those group by footer.

thanks in advance for your response.

Problem to group radio button across gridview rows

In general no one can easily group or make a single selection from radio button list inside gridview rows. There are a lot of way to make a single or unique selection from list. Here i want to share how i can address this problem in the most easiest way. Googling the problem most of the cases i saw the grouping in horizontal way. Thats why i tried to group the radio buttons in vertical manner. Let i have a requirement like below:

Group Calendars in SharePoint 2010

One of the many requests I had in SharePoint 2007 was the ability to place SharePoint Calendars on top of each other like you can in Outlook 2007 saving you having to look at each and work out when the best time is for a meeting.

ListViewControl - how to group items by their value, for eg. date range



I have a table containing courses, columns are 

Name - "Yoga Classes"

DateStart - "2/23/2010"

DateEnd - "2/24/2010"

I am using ListView Control to bind it, is there a way to display them and group them by Month? 

for eg.


Piano Class (10th Jan 2010 - 11th Jan 2010)
Guitar Class (10th Jan 2010 - 11th Jan 2010)


Yoga Class (15th Feb 2010 - 16th Feb 2010)

Thanks for help.

Create ID (uniqueid?) from two fields when data is entered


I need to create an ID from two fields when they are entered into the db for the first time.  I thought Uniqueidentifer would do this, but it looks like uniqueidentifier is random and i have no control of the process. 

My user will enter 4 letters into a column called INIT and 4 numbers into a column called NUMB.  What I would like to do is create an id by combining those fields.

How can I do this?



LINQ with GridView and edit fields


My project includes a grid view which displays information of inventory items (Assets), data is quried from AssetTable. The GridView has a command field to allow editing, below is a description of the tables and how data is displayed


BuildingTable: (BuildingID, BuildingName)

AssetTable: (BuildingID,..,....,....)


ItemTemplate: Using a LINQ query I join the two table and displays in a label control a string which includes BuildingID and BuildingName (5 North Building)

 EditItemTemplate: Using a LINQ query I populate a DropDownList with strings of BuildingID and BuildingName same as above.
Here  issue which I need to resolve:
1.  ItemTemplate display the correct information (BuildingID BuildingName) but when I switch to EditItemTemplate the pair that is 
displayed is the first one on the list, how do I make is scroll to the item which was displayed in the label ?
<asp:CommandField ShowEditButton="True" >
                    <ControlStyle Wi

I want Er Diagram for Fees System of small institution ,can u plz guide me what fields are necessary


I want Er Diagram for Fees System of small institution ,can u plz guide me what fields are necessary to store Fees information ...


Combining two LDAP queries


Hey guys, I have these two queries I'd like to combine into one.  Is there any way of doing it?
Query 1: (&(!cn=SystemMailbox{*})(&(&(ou>="")(name=executive*)(objectCategory=organizationalUnit)(ou=*operations))))
Query 2: (&(!cn=SystemMailbox{*})(&(ou>="")(name=50*)))
Thanks in advance.

Hey guys, I have these two queries I'd like to combine into one.  Is there any way of doing it?


How do I get the emails of all the members of a given group in ActiveDirectory - Need help



  I have a need to send out emails to all the people who are in a given group say "HR Department". I need to be able to get all the emails through a for loop and then as it retrieves I should send emails to them. Can some one please help me with the code

this is what I came up with but not sure how to go about writing a for loop to get all the emails in the given group.

public static string SendEmails(string loginName)
        string Department = "HR Department"
        string userName = ExtractUserName(loginName);
        DirectorySearcher search = new DirectorySearcher();
        search.Filter = String.Format("(SAMAccountName={0})", userName);
        //search.Filter = String.Format("(SAMAccountName={FAY ImprovmentForm})", userName);
        //LdapSearcher.Filter = string.Format("(&(objectClass=user)(department={0}))", Department); 
        //search.Filter = string.Format("(&(objectClass=group)(SAMAccountName=" + Department + "))", userName);

Need Help in LINQ query for group By with chunks of record


I am assigning and unique id [strShipperIdSequence] on my List on bases of some properties which are grouped together uniquely.
Now what i needed is that my group should be further break down to some maximum amount of chunks.[Let say 10]
that mean's even i am having Same value in 12 records i should get 2 groups[I of 10 items and other of 2 items]

var uniqueGroups = objMdbContentInfoList.GroupBy(p => new
}).Select(g => g.First()).ToList();
foreach (var objUnique in uniqueGroups)
string strShipperIdSequence = APIGlobalMethods.GetShipperRequestID();
foreach (MdbContentInfo obj in objMdbContentInfoList.FindAll(h => (h.CON_ENTRY_POINT == objUnique.CON_ENTRY_POINT &&
h.APPTType == objUnique.APPTType &&

Test Run: Group Determination In Software Testing


There is a large body of research on group techniques to determine the best alternative from a set of options. Dr. James McCaffrey outlines five of them.

Dr. James McCaffrey

MSDN Magazine November 2008

ASP.NetWindows Application  .NET Framework  C#  VB.Net  ADO.Net  
Sql Server  SharePoint  Silverlight  Others  All   

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend