Forum Replies Created

Viewing 15 posts - 2,251 through 2,265 (of 8,731 total)

  • RE: difference betwwn inner join and intersect in sql

    An easy way to understand it, is that JOINs add columns while UNION/EXCEPT/INTERSECT only handle rows.

    Of course, if you see a Venn diagram, they'll be the same. The difference come...

    Luis C.
    General Disclaimer:
    Are you seriously taking the advice and code from someone from the internet without testing it? Do you at least understand it? Or can it easily kill your server?

    How to post data/code on a forum to get the best help: Option 1 / Option 2
  • RE: Searching set of words by ignoring spaces

    Sergiy (8/24/2016)


    There was an article from Jeff Moden how to replace any number of consecutive spaces with a single one without recurring REPLACE calls.

    I don't have it handy, but it...

    Luis C.
    General Disclaimer:
    Are you seriously taking the advice and code from someone from the internet without testing it? Do you at least understand it? Or can it easily kill your server?

    How to post data/code on a forum to get the best help: Option 1 / Option 2
  • RE: Using coalesce in a single table

    I mean that instead of the proposed solution:

    SELECT DISTINCT

    ID,

    Brand = STUFF(( SELECT ',' + Brand

    ...

    Luis C.
    General Disclaimer:
    Are you seriously taking the advice and code from someone from the internet without testing it? Do you at least understand it? Or can it easily kill your server?

    How to post data/code on a forum to get the best help: Option 1 / Option 2
  • RE: Using coalesce in a single table

    GilaMonster (8/24/2016)


    Luis Cazares (8/24/2016)


    Also, using DISTINCT is expensive. In this case, you should try using GROUP BY.

    Which will behave exactly the same as the DISTINCT. Since he wants distinct values,...

    Luis C.
    General Disclaimer:
    Are you seriously taking the advice and code from someone from the internet without testing it? Do you at least understand it? Or can it easily kill your server?

    How to post data/code on a forum to get the best help: Option 1 / Option 2
  • RE: Insert changed data

    Let's see if I understand correctly.

    You want to change the value of a column to track changes on the table? Are your queries prepared to handle soft deletes? If you...

    Luis C.
    General Disclaimer:
    Are you seriously taking the advice and code from someone from the internet without testing it? Do you at least understand it? Or can it easily kill your server?

    How to post data/code on a forum to get the best help: Option 1 / Option 2
  • RE: Using coalesce in a single table

    chozhanvijay 23273 (8/24/2016)


    hi Luis,

    I think i should use the STUFF instead of the coalesce here. As coalesce is for returning the non null values. Can you please help me out...

    Luis C.
    General Disclaimer:
    Are you seriously taking the advice and code from someone from the internet without testing it? Do you at least understand it? Or can it easily kill your server?

    How to post data/code on a forum to get the best help: Option 1 / Option 2
  • RE: Using coalesce in a single table

    Why do you think that you need coalesce? What do you think coalesce does? If you're not sure, read the following link: https://msdn.microsoft.com/en-us/library/ms190349.aspx

    To solve your problem, you might want to...

    Luis C.
    General Disclaimer:
    Are you seriously taking the advice and code from someone from the internet without testing it? Do you at least understand it? Or can it easily kill your server?

    How to post data/code on a forum to get the best help: Option 1 / Option 2
  • RE: Pivot Help

    You can use Cross tabs.

    SELECT Region, District, LocID,

    MAX(CASE WHEN Title = 'IT Director' THEN Cnt ELSE 0 END),

    MAX(CASE WHEN Title = 'IT Manager' THEN Cnt ELSE 0 END)

    --etc

    FROM...

    Luis C.
    General Disclaimer:
    Are you seriously taking the advice and code from someone from the internet without testing it? Do you at least understand it? Or can it easily kill your server?

    How to post data/code on a forum to get the best help: Option 1 / Option 2
  • RE: how to select first column with a specified value in a day range

    JALLYKAMOZE (8/24/2016)


    Thanks Sir,

    This worked perfectly

    Great! Do you understand why and how it works?

    Luis C.
    General Disclaimer:
    Are you seriously taking the advice and code from someone from the internet without testing it? Do you at least understand it? Or can it easily kill your server?

    How to post data/code on a forum to get the best help: Option 1 / Option 2
  • RE: Searching set of words by ignoring spaces

    Here's another option. Note that these solutions won't eliminate tabs, line feeds or other spacing characters. I created a function to avoid making the query too complex and to reuse...

    Luis C.
    General Disclaimer:
    Are you seriously taking the advice and code from someone from the internet without testing it? Do you at least understand it? Or can it easily kill your server?

    How to post data/code on a forum to get the best help: Option 1 / Option 2
  • RE: how to select first column with a specified value in a day range

    If you want to create the table with a column named as the first occurrence, you need to use dynamic sql. That's just wanting problems, IMHO.

    Otherwise, you could do this:

    IF...

    Luis C.
    General Disclaimer:
    Are you seriously taking the advice and code from someone from the internet without testing it? Do you at least understand it? Or can it easily kill your server?

    How to post data/code on a forum to get the best help: Option 1 / Option 2
  • RE: how to select first column with a specified value in a day range

    JALLYKAMOZE (8/23/2016)


    Luis Cazares (8/23/2016)


    You can use a CASE expression for this:

    SELECT CASE WHEN Monday = 1 THEN 'Monday'

    WHEN Tuesday =...

    Luis C.
    General Disclaimer:
    Are you seriously taking the advice and code from someone from the internet without testing it? Do you at least understand it? Or can it easily kill your server?

    How to post data/code on a forum to get the best help: Option 1 / Option 2
  • RE: how to select first column with a specified value in a day range

    You can use a CASE expression for this:

    SELECT CASE WHEN Monday = 1 THEN 'Monday'

    WHEN Tuesday = 1 THEN 'Tuesday'

    ---etc

    ...

    Luis C.
    General Disclaimer:
    Are you seriously taking the advice and code from someone from the internet without testing it? Do you at least understand it? Or can it easily kill your server?

    How to post data/code on a forum to get the best help: Option 1 / Option 2
  • RE: Converting Varchar to Int Error

    tstagliano (8/23/2016)


    I have the below script and when i run it i keep getting the error "Conversion failed when converting the varchar value '?' to data type int" and i...

    Luis C.
    General Disclaimer:
    Are you seriously taking the advice and code from someone from the internet without testing it? Do you at least understand it? Or can it easily kill your server?

    How to post data/code on a forum to get the best help: Option 1 / Option 2
  • RE: how to select first column with a specified value in a day range

    JALLYKAMOZE (8/23/2016)


    I HAVE A TABLE RANGING FROM MONDAY, TUESDAY,WEDNESDAY,THURSDAY,FRIDAY,SATURDAY,SUNDAY

    THESE TABLES HAVE VALUES BETWEEN 0 AND 1 EG,

    MONDAY : 0, TUESDAY :1,WEDNESDAY : 0,THURSDAY:1,FRIDAY:1. SATURDAY:1 SUNDAY:1

    HOW CAN I SELECT ONLY...

    Luis C.
    General Disclaimer:
    Are you seriously taking the advice and code from someone from the internet without testing it? Do you at least understand it? Or can it easily kill your server?

    How to post data/code on a forum to get the best help: Option 1 / Option 2

Viewing 15 posts - 2,251 through 2,265 (of 8,731 total)