Concatenate 3 Fields With Group By

This is the SQL Statement I want to run, but it keeps telling me it is invalid in the select list as it is not included in an aggregate function.
Select
Count(EmpID),
(FirstName+' '+LastName) As Name,
(City+' '+State+' '+Zip) As Location,
DriveTime
From employeeDatabase
Where DriveTime is not null
Group By DriveTime

Are you looking for the below: If not, please provide DDL and sample data.
create table employeeDatabase(Firstname varchar(10),LastName varchar(10),City varchar(10),
State varchar(10),Zip varchar(10), DriveTime int)
Insert into employeeDatabase
Select 'as','sdf','qwe','qwe','123',12
Insert into employeeDatabase
Select 'as','sdf','qwe','qwe','123',12
;with cte
as
Select
(FirstName+' '+LastName) As Name,
(City+' '+State+' '+Zip) As Location,
DriveTime,COUNT(1) Over(PARTITIon by DriveTime) Rn
From employeeDatabase
Where DriveTime is not null
) Select * From cte
Drop table employeeDatabase

Similar Messages

  • Concatenate 6 Fields with Condition

    Hello all,
    How r u ?
    In a scenario we have to Concatenate 6 Fields in BW like,
    /BIC/ZCV_ANAAM - FirstName
    /BIC/ZCV_TUGBN  - Initial
    /BIC/ZCV_GBNAM - MiddleName
    TXTSH                  - Gender
    /BIC/ZCV_VLETR   - LastName
    /BIC/ZCV_TUSEL   - NickName
    and in this Format
    <b>FirstName - Initial MiddleName, Gender LastName NickName</b>
    In the Transfer Routine I used Formula option and gave like this,
    <b>/BIC/ZCV_ANAAM & '-' & /BIC/ZCV_TUGBN &' ' & /BIC/ZCV_GBNAM &',' & TXTSH &' ' & /BIC/ZCV_VLETR &' ' & /BIC/ZCV_TUSEL</b>
    but the system throws this error
    "Invalid formula element: ' & /BIC/ZCV_TUSEL"
    Also, the condition is <b>"Initial MiddleName" SHOULD NOT appear
    If MiddleName = " "(Empty)</b>
    How could I arrive this with Formula or Routine ?
    Best Regards....
    Sankar Kumar
    +91 98403 47141

    Hi Sankar,
    I would suggest you to use a routine to achieve the result.I am not sure of the ABAP syntax below, but try this logic.
    "Declare a variable of character type with the total length."
    data : <Variable Name>(100) type c.
    If TRAN_STRUCTURE-<Field Name>MiddleName is initial.
    " Dont include Middle name in this list"
    concatenate TRAN_STRUCTURE-/BIC/ZCV_ANAAM  TRAN_STRUCTURE-/BIC/ZCV_TUGBN..... into <Variable Name>
    else
    " Include Middle name in this list"
    concatenate TRAN_STRUCTURE-/BIC/ZCV_ANAAM  TRAN_STRUCTURE-/BIC/ZCV_TUGBN..... into <Variable Name>
    endif.
    You can use this variable name as your final result
    hope it helps,
    regards,
    Parth.

  • Concatenate a field in internal table without loopat.

    In an internal table,
    I need to update one field (all rows) concatenate that field with a value say '999'.
    Is it possible to do this in a single MODIFY statement without using loopat condition or any other best possible way to do it?

    yes, it is possible without LOOP:
    MODIFY itab FROM workarea WHERE condition TRANSPORTING field.
    workarea has to like a single line of the internal table and has to contain the value you want to transfer
    after TRANSPORTING you name the field you want to change
    you can check the complete syntax (with examples) in SAPHelp

  • Set "peoples or groups" field with current user "login name" in sharepoint list form using javascript

    hi friends
    i am trying to set peoples or groups field in sharepoint  list form with current user login name
    here my code
    <script src="http://ajax.aspnetcdn.com/ajax/jquery/jquery-1.9.0.js"></script>
    <script type="text/javascript">
    $(document).ready(function NewItemView () {
    var currentUser;
        if (SP.ClientContext != null) {
          SP.SOD.executeOrDelayUntilScriptLoaded(getCurrentUser, 'SP.js');
        else {
          SP.SOD.executeFunc('sp.js', null, getCurrentUser);
        function getCurrentUser() {
          var context = new SP.ClientContext.get_current();
          var web = context.get_web();
          currentUser = web.get_currentUser();
          context.load(currentUser);
          context.executeQueryAsync(onSuccessMethod, onRequestFail);
        function onSuccessMethod(sender, args) {
          var account = currentUser.get_loginName();
          var accountEmail = currentUser.get_email();
          var currentUserAccount = account.substring(account.indexOf("|") + 1);
        SetAndResolvePeoplePicker("requester",account);
    // This function runs if the executeQueryAsync call fails.
        function onRequestFail(sender, args) {
          alert('request failed' + args.get_message() + '\n' + args.get_stackTrace());
     function SetAndResolvePeoplePicker(fieldName, userAccountName) {
       var controlName = fieldName;
        var peoplePickerDiv = $("[id$='ClientPeoplePicker'][title='" + controlName + "']");
        var peoplePickerEditor = peoplePickerDiv.find("[title='" + controlName + "']");
        var spPeoplePicker = SPClientPeoplePicker.SPClientPeoplePickerDict[peoplePickerDiv[0].id];
        peoplePickerEditor.val(userAccountName);
        spPeoplePicker.AddUnresolvedUserFromEditor(true);
    </script>
    but it is not working
    please help me

    Hi,
    According to your post, my understanding is that you wanted to set "peoples or groups" field with current user "login name" in SharePoint list form using JavaScript.
    To set "peoples or groups" field with current user "login name”,  you can use the below code:
    <script src="http://ajax.aspnetcdn.com/ajax/jquery/jquery-1.9.0.js"></script>
    <script type="text/javascript">
    function SetPickerValue(pickerid, key, dispval) {
    var xml = '<Entities Append="False" Error="" Separator=";" MaxHeight="3">';
    xml = xml + PreparePickerEntityXml(key, dispval);
    xml = xml + '</Entities>';
    EntityEditorCallback(xml, pickerid, true);
    function PreparePickerEntityXml(key, dispval) {
    return '<Entity Key="' + key + '" DisplayText="' + dispval + '" IsResolved="True" Description="' + key + '"><MultipleMatches /></Entity>';
    function GetCurrentUserAndInsertIntoUserField() {
    var context = new SP.ClientContext.get_current();
    var web = context.get_web();
    this._currentUser = web.get_currentUser();
    context.load(this._currentUser);
    context.executeQueryAsync(Function.createDelegate(this, this.onSuccess),
    Function.createDelegate(this, this.onFailure));
    function onSuccess(sender, args) {
    SetPickerValue('ctl00_m_g_99f3303a_dffa_4436_8bfa_3511d9ffddc0_ctl00_ctl05_ctl01_ctl00_ctl00_ctl04_ctl00_ctl00_UserField', this._currentUser.get_loginName(),
    this._currentUser.get_title());
    function onFaiure(sender, args) {
    alert(args.get_message() + ' ' + args.get_stackTrace());
    ExecuteOrDelayUntilScriptLoaded(GetCurrentUserAndInsertIntoUserField, "sp.js");
    </script>
    More information:
    http://alexeybbb.blogspot.com/2012/10/sharepoint-set-peoplepicker-via-js.html
    Best Regards,
    Linda Li
    Linda Li
    TechNet Community Support

  • Linking/Grouping Text Fields with a Check Box Field

    Disclaimer: I know nothing about coding/scripting in Acrobat (or in any language, for that matter).
    I have 4 sets of text fields, call them A, B, C, and D. All of the fields in set A will have a value entered. There are 10 fields in set A while sets B, C, and D may have as many as 104. Sets B, C, and D will always have a one-to-one-to-one correspondence with each other (B1 is associated with C1 and D1 only and so on). My dilemma/desire is two fold:
    First:
    I want to be able to group 3 to 4 of the fields in set C if I tick a check box/radio button/whatever field type works. When the fields are grouped, I want their values to be the same within the grouping. These fields should also be ungrouped when the marker field is unchecked/deactivated. No field will ever be in any more than one group.
    Second:
    I want values for set B to equal a value of set A if there is a value entered in that B's corresponding C field.
    Please don't hesitate to point out where I can make any of this clearer.
    Thank you in advance,
    Joseph
    P.S.
    If one or both of these is not doable in Acrobat, would you please kindly point me to a program that can do this?

    Steve,
    Sorry, I referenced InDesign and this file was created in Illustrator. (I have been working with numerous files created in both InDesign and Illustrator, with numerous challenges). I do not have the native document nor Illustrator software, only Acrobat. When I previously loaded the InDesign-created pdf file(s) into Acrobat, I was unable to use the Text TouchUp Tool because I do not have the fonts on my system that were used to create the documents in InDesign, thus I am denied access to the text. With this file, created in Ilustrator; I assume because the text resides within the image created that encompasses the entire page, the Text TounchUp Tool and Object Tool have no response when I click on the page after activating the tools with a click, although the Tool Bar allows me to click on the icons to activate the functions.
    I have read elsewhere that InDesign and Illustrator files are exported as images, thus requiring either Photoshop or Illustrator to fully edit outside of the originating software. However, I was hoping that I could create interactive forms by overlaying fields with Live Cycle Designer - I did not anticipate the default setting of the check box labels being unchangeable. Sounds like I am at a dead-end with this issue??
    Linda

  • Sql with groups, aggregates and fields of that aggregates

    lets say I have a table Students and want to group the students by major, and then for each group display the maximum age, and them for that maximum age display the name of that student
    I know how to do the grouping and max aggregate, I know how to do the max aggregate and the name of the max aggregate, but I'm having trouble doing all 3 together. Any help would be appreciated. Thanks.

    ok, well I was using an hypotethical example. What I'm really dealing with are many fields with from many tables and 2 groups with 2 nested aggregates. The original query from Crystal Reports doesnt use aggregates, its all done within report. I'm converting it to SSRS which doesnt support nested aggregates so I'm trying to do one of the aggregates in the query and then the other aggregate within the report.
    table students:
    name
    age
    major
    so the original query would look like:
    select name, age, major
    from student
    I'm trying to do something like:
    select max(age), name from max(age), major
    from student
    group by major
    Edited by: nwill on Feb 19, 2009 3:22 PM

  • How to concatenate single quote with any field like 'VBAK'

    Hi,
    How to concatenate single quote with any fields.
    say for example I have table name as MARA, I have to pass that table name to other fields with single quote , like I have to pass that as
    tab name = 'MARA'.
    but how to do this,
    below statement will not work
    concatenate '''  'MARA'   ''' into string.. it's giving syntax error...
    Regards,
    Mrunal

    gv_name = 'MARA'.
    gc_quote = '''.
    CONCATENATE gc_quote gv_name gc_quote INTO value.
    Pushpraj

  • Strange error F5272 with field status group.

    Dear all,
    I faced a strange problem when making manual FI posting through FB01.
    The system issues an error:
    Rules for posting key 27 and acct 60010100 set incorrectly for "PRODPER" field
    Message no. F5272
    Diagnosis
    One of the rules specifies that the field demands a required entry, the other rule says that the field is to be suppressed.
    Procedure
    Correct one of the two rules for the field selection.
    You find the field status group in the G/L account master record:
    Execute function
    You can find the rules for the field status group in the Financial Accounting Implementation Guide in the activity Maintain field status variants.
    You can find the posting key in the Financial Accounting Implementation Guide in the activity
    Define posting key.
    But I could not find the field PRODPER in group status field for G/L account (T-code OBC4) or posting key (T-code OB41). Could you please tell me why the system issues such a strange error?
    I have been searching all day long in forum, but could not find the answer to this question.
    Best regards,
    LInh.

    Check then field status will be same with these two field status OBC4 and OB41 - Posting key.
    The field is "Joint Venture Recovery Indctr" for the field name PRODPER.
    This field must be suppressed in those one and other has another status.
    Check these should be same.
    OB41 - Posting key 27.
    As the field is suppressed here, then it will be also suppressed in OBC4.
    First go to FS00, enter the G/L account, click on the tab Create/bank/interest, then take the Field status group
    Then go to OBC4, Check the field selection group for the field "Joint Venture Recovery Indctr"
    It should be also suppressed. Check the same in your system.

  • How to set a string field with people picker control group

    Hi Guys
    I have a problem with a form list, when I need to set a string field with de content of people picker control that have more than one "user".
    Is there any way to put in string a list of user like the people picker control shows in a form?
    The really problem is I don't know how to read an array of user in a formula rule.
    any example or idea should be appreciated.
    tnks.

    Hi ,
    Please try out in following way :
            /// <summary>
            /// Set value to people picket control
            /// </summary>
            /// <param name="key"></param>
            /// <param name="ppl"></param>
            /// <param name="item"></param>
            private void SetDatatoPeopleEditor(string key, PeopleEditor ppl, SPListItem item)
                try
                    if (item[key] != null)
                        string users = string.Empty;
                        SPFieldUserValueCollection userCol = new SPFieldUserValueCollection(web, item[item.Fields.GetField(key).Id].ToString());
                        foreach (SPFieldUserValue usrItm in userCol)
                            users += usrItm.User.ToString() + ",";
                        ppl.CommaSeparatedAccounts = users.Remove(users.LastIndexOf(","), 1);
                catch (Exception ex)
                    lblErrorMessage.Text = ex.Message;
    private SPUser GetAccountName(PeopleEditor accountPE)
                SPUser user = null;
                string strAccountName = String.Empty;
                try
                    for (int i = 0; i < accountPE.ResolvedEntities.Count; i++)
                        PickerEntity objEntity = (PickerEntity)accountPE.ResolvedEntities[i];
                        user = web.AllUsers[objEntity.Key];
                    return user;
                catch (Exception ex)
                return user;
    It works for me .

  • Mandatory fields With reference to Material types

    Dear Gurus,
    I need to make few fields as mandatory with reference to material types while creation of the material master data.
    For example:
    For Semi finished and Finished Schedule margin key is required(mandatory)
    For Raw Materials Schedule margin key is optional.
    Regards,
    Siddharth

    Hi
    find  following step to make field mandatory for material type
    Follow the stpes for making field as optional, required entry
    1 click the tab ,(Which is u want to be Required entry )and get the field name by pressing F1 key and then
    2.Go to T.Code: OMSR and enter that field name and get Selection Group
    once you get selection group and field name
    3 Use t.Code: OMS2 and click your material type and in next screen check Field reference ( you have assigned for material type; example :;For ROH material type the Field reference is ROH
    3. Use T.code:OMS9,, Double Click your Field Reference and select field selection Group , & select round box of Required Entry or optional and save
    check following link you will get clear idea [How to configure the fields required for each Material type ?;
    Regards
    Kailas ugale

  • Selection criteria are not applied to summary fields on group footers.

    I wonder if anyone can help me with this problem.  I am using Crystal reports version 11.2, and my data source is a Sql Server view.
    The records on the view have a date field, and I have selected all records within a given date range in "Selection Formulas".
    The records are then grouped, and the Crystal summary facility used to summarise number fields on the group footers.
    So for example, if my view contains four records, one with field "amount" = 2, one with field "amount" = 8, one with field "amount" = 6, one with field "amount" = 3, but only the first two records are within the valid date range, you would expect to see the first two records listed out at detail level, then field "amount" summarised at group level, with a summarised value of 10.
    ie ....                record1                      2
                           record2                      8   
                           group level total         10
    This works fine when I run the report using Crystal's "print preview" facility.  However, when the report is run from within an application written in C#.NET, the selection criteria are not applied to the summary field, so you get ..
                           record1                      2
                           record2                      8   
                           group level total          19
    I tried putting the date selection criteria at both record and group level, but that did not work.
    I googled the problem and found an article explaining that Crystal first performs the record-level selection, then it creates the groups and totals up any summary fields, and only then does it apply the group-level selection criteria, which can lead to problems like the one I have described above.  However, since I have put my date selection criteria at both record and group level, I do not understand why I still get the problem.
    In one report I got round this problem by creating a formula that returned zero if the record date was outside of the valid date range, and returned the number field to be summarised if the date was valid, then summarising that formula, instead of summarising the number field directly.
    In other reports I created one formula to set a shared variable as zero, then another formula to accumulate it at detail record level, then another formula to display the variable at the group footer.  In other words, I did not bother with the Crystal summary facility at all, but created my own summary facility.
    While googling the problem to see what other people did in this situation, I noticed that most fixes used variations of the "shared variables and formulae" fix to get round the problem.
    The problem is that I have lots of complex reports and it will take ages to replace the summarised fields with shared variables and formulae.  The reports were initially tested with "Print Preview" so we did not notice this problem until the C#.Net application was ready to use them.  And I can't believe that you are simply meant to ignore the summary facility and re-invent the wheel by doing it all manually.
    Please tell me that there is something simple that I have been doing wrong!!!  If I have not given enough information for you to answer, please let me know.
    Thanks,
    Anne-Marie

    Hi, Anne-Marie;
    You may be running into a common issue that is docuemented here:
    [SelectionFormula|https://www.sdn.sap.com/irj/servlet/prt/portal/prtroot/com.sap.km.cm.docs/oss_notes_boj/sdn_oss_boj_erq/sap(bD1lbiZjPTAwMQ==)/bc/bsp/spn/scn_bosap/notes%7B6163636573733d36393736354636443646363436353344333933393338323636393736354637333631373036453646373436353733354636453735364436323635373233443330333033303331333233303334333833393335%7D.do]
    Regards,
    Jonathan
    Edited by: Jonathan Parminter on Mar 16, 2009 8:03 AM

  • Field Status Group influence when Purchase Requisition being created

    Hi!
    I have a requirement from a client regarding the influence of the Field Status Group on Purchasing Documents.
    A Filed Status Group has been created in which has the CO/PP order set as Required entry for the Account Assignment.
    This Group was then assigned to a GL Account.
    When a Goods Receipt (MIGO) against a Purchase Order is entered for a GL which requires an Internal Order, the standard error message "Field Order is a required field for G/L account 0010 4105000100 " (message # F5808) appears if the Account Assignment on the PO is incorrect & no Internal Order has been entered.
    This is fine & is how the system operates as standard.
    However, the requirement from my client is to make this error message appear when a Purchase Requisition is being entered on the system, before it is converted to a PO & then receipted.
    They believe that calling the message at the point of GR is too late in the process.
    Could anyone advise on any possible BAPI, etc which could help us with this requirement??
    Thanks,
    k

    I have gone to the Tcode which has been given,
    In the first field , I have given the company code,
    in the second field , I have given  call Plant (0002)
    Validation ......how do i give the validation please let me know
    With Regards,

  • Field Purchasing Group is disable in Shopping Cart

    Hi Expert,
    I have an issue in Shopping Cart. When i create Shopping cart in SRM, field for Purchasing Group is disable.
    I don't know why it's happened. 
    Because of this, when i create PO from SC in SRM (From Source of Supply), field purchasing group and purchasing organization in PO window is disable also and has no value (blank). And we can not edit the value also.
    Coud you help me please?
    Warm Regards,
    Rhesa Syahrial

    Anil
    Did you maintain Purch Group's Responsibility tab with Org ID of the user Org and responsible Prod categories.
    Then this Purch grp will be picked up when user from that org unit is created the SC.
    PS : Reward points if helpful.
    Regards
    Jagadish

  • The field "GLTPC" is unknown, but there is a field with the similar name*

    Hi all
    When i am running the report painter reports in SAP
    i am getting this error .
    Syntax error in program    SAPFGRWG
    in include                  FGRWGE60
    in line                      19
    Last changed by            SAP
    Author                     SAP
    The field "GLTPC" is unknown, but there is a field with the similar name
    "GLTPC".*
    Please help me whenever
    Regards,
    suchithra
    Edited by: Rob Burbank on May 22, 2009 9:00 AM

    Hi All
    All 8A group Report painter reports i.e GLPCt table Reports are not executed properly
    Can you please help me out
    Regards,
    suchithra

  • Report on field Corporate Group (Group key) of the Vendor Master

    Hi,
    We have a vendor with for example 4 different locations. In SAP we have therefore 4 different vendor masters. We want to report not only per seperate vendor master but also we want to report on the vendors corporate level. Now we have populated the field Corporate group (Group key) on all 4 vendor masters.
    Are there any financial reports where you can use the field Corporate group (Group key) from the vendor master to consolidate on?
    If there are other solutions for reporting in this case then please let me know.
    Regards,
    Roel van Loon

    Hi
    I hope it is corporate group under account control tab in VM general data. If you maintain any data here - you can use vendor open line item report (FBl1n) to get the report on open items cleared items for these vendors collectively. You can see this option in dynamic selection in report - vendor master tab.
    Thanks
    Edited by: Praveen Raghavendra on Jan 16, 2009 2:38 PM

Maybe you are looking for