Forum Replies Created

Viewing 15 posts - 1,081 through 1,095 (of 1,420 total)

  • Reply To: Case when with a Pivot

    select
    Cust_num, Co_num,
    sum(amount) Total,
    sum(iif(floor(datediff(d,due_date,getdate())/30)=0,amount,0)) [1-30 Days],
    sum(iif(floor(datediff(d,due_date,getdate())/30)=1,amount,0)) [31-60 Days],
    sum(iif(floor(datediff(d,due_date,getdate())/30)=2,amount,0)) [61-90 Days],
    sum(iif(floor(datediff(d,due_date,getdate())/30)>2,amount,0)) [>90 Days]
    from EES_App.dbo.artran_all
    group by Cust_num, Co_num;

    Aus dem Paradies, das Cantor uns geschaffen, soll uns niemand vertreiben können

  • Reply To: Select return no records

    jcelko212 32090 wrote:

    I think this is horrible advice. The customer number is an identifier for a customer (I assume), and not a magnitude or quantity of some attribute. Therefore, according to...

    Aus dem Paradies, das Cantor uns geschaffen, soll uns niemand vertreiben können

  • Reply To: Top 10, count Distinct of multiple columns in select statement

    Something like this maybe

    ;with
    SiteInfo(SiteId, SiteName, JobId, Grade) as (
    select 1, 'aaa', 1, 'a'
    union all
    select 1,...

    Aus dem Paradies, das Cantor uns geschaffen, soll uns niemand vertreiben können

  • Reply To: Slow Query when add 1 additional field

    To see more about what Jonathan's suggesting maybe have a look at this page:

    https://docs.microsoft.com/en-us/sql/relational-databases/indexes/create-indexes-with-included-columns

    It could be looked at like there're 2 ways to "include" columns in an index: 1) as...

    Aus dem Paradies, das Cantor uns geschaffen, soll uns niemand vertreiben können

  • Reply To: Query Required this scenario

    drop table if exists #tblRecorddetails;
    go
    create table #tblRecorddetails(
    Recordid int,
    Userid ...

    Aus dem Paradies, das Cantor uns geschaffen, soll uns niemand vertreiben können

  • Reply To: In varchar column add numbers and show strings

    drop table if exists #temp;
    go
    create table #temp (
    userid int , rid varchar(10), value varchar(100));

    insert #temp(userid,rid,value) values
    (1,'D01','3'),
    (1,'D01','4'),
    (2,'C01','hey'),
    (2,'C01','1');

    with t_cte(userid,rid,value) as (
    select
    ...

    Aus dem Paradies, das Cantor uns geschaffen, soll uns niemand vertreiben können

  • Reply To: Only one expression can be specified in the select list when the subquery is not

    Maybe this could work too

    select 
    coalesce(ph.username, (select Message from itrm_itbf.temp.security))
    from
    ITRM_ITBF.[PMD].[PMD_HR] ph
    join
    ITRM_ITBF.[Dflt].[MANUAL_LSV_PERMISSIONS] mlp on ph.username=mlp.username
    ...

    Aus dem Paradies, das Cantor uns geschaffen, soll uns niemand vertreiben können

  • Reply To: stored procedure return values

    Instead of returning the SSN (which is being sent to the procedure already) could you return COUNT(*)?  Count always returns a value.

    Aus dem Paradies, das Cantor uns geschaffen, soll uns niemand vertreiben können

  • Reply To: insert random value from predefined list of possible values

    marchello wrote:

    It's data obfuscation project, thus no strict rules what value should be, rather it should be random. Each row should have its own value. When we are out of...

    Aus dem Paradies, das Cantor uns geschaffen, soll uns niemand vertreiben können

  • Reply To: insert random value from predefined list of possible values

    It randomly picks one of the words

    ;with data_cte(which_word) as (
    select 'some' union all select 'word' union all select 'here')
    select top(1)
    which_word
    from
    ...

    Aus dem Paradies, das Cantor uns geschaffen, soll uns niemand vertreiben können

  • Reply To: Query help for special condition

    This is a beginning and it might get the OP past the id assignment issue.

    drop table if exists #src_data;
    go
    create table #src_data(
    EmpId ...

    Aus dem Paradies, das Cantor uns geschaffen, soll uns niemand vertreiben können

  • Reply To: Query help for special condition

    sqlenthu 89358 wrote:

    Now while i was trying to implement merge, problem is how to assign new identifier value for new record (it should be max value +1 , and this column...

    Aus dem Paradies, das Cantor uns geschaffen, soll uns niemand vertreiben können

  • Reply To: expand field and fill with zeros

    Jeff Moden wrote:

    Right there with you.  I wouldn't bother on that other thread, though.  That subject keeps cropping up over and over and over and some of the participants do too. ...

    Aus dem Paradies, das Cantor uns geschaffen, soll uns niemand vertreiben können

  • Reply To: expand field and fill with zeros

    Jeff are the results reversed?  It lists FORMAT d14 method as 802ms.  Maybe copy/paste gone off?

    Jeff Moden wrote:

    And, please... for the love of your servers and your customers, stop all the...

    Aus dem Paradies, das Cantor uns geschaffen, soll uns niemand vertreiben können

  • Reply To: Replacing / Removing All Text In Multiple Sets of Characters in SQL

    Jeffrey Williams wrote:

    @scdecade - your solution will not work for the OP.  The trim function is not available on SQL Server 2016 and would need to be replaced with a rtrim(ltrim(...)). ...

    Aus dem Paradies, das Cantor uns geschaffen, soll uns niemand vertreiben können

Viewing 15 posts - 1,081 through 1,095 (of 1,420 total)