Where filter question

  • Can anyone please tell me what the below where filter is doing?

    select TargetSafetySockQty from SSInventoryFact where isnull(TargetSafetyStockQty,0) <> 0

    Thanks!

    A clever person solves a problem. A wise person avoids it. ~ Einstein
    select cast (0x5365616E204465596F756E67 as varchar(128))

  • The where Clause is filtering TargetSafetyQty that are Zero's or nulls.

    E.g of a code snippet that might help u understand this better

    [Code]

    CREATE TABLE #Temp

    (

    ID INT IDENTITY(1,1) NOT NULL,

    Qty INT

    )

    INSERT INTO #Temp(Qty)

    SELECT 1

    UNION ALL

    SELECT NULL

    UNION ALL

    SELECT 0

    UNION ALL

    SELECT 3

    SELECT * FROM #Temp WHERE ISNULL(Qty,0) <>0

    SELECT * FROM #Temp

    WHERE

    (

    Qty IS NOT NULL

    AND

    Qty <> 0

    )

    DROP TABLE #Temp

    [/Code]

  • where isnull(TargetSafetyStockQty,0) <> 0

    isnull is a proprietary version of COALESCE, but with just a single replacement value.

    From BOL

    ISNULL (check_expression ,replacement_value )

    Check BOL: http://msdn.microsoft.com/en-us/library/ms184325.aspx

    So the where clause will return only rows that have a value (not null) in TargetSafetyStockQty and that value must not be 0 (zero).

    Johan

    Learn to play, play to learn !

    Dont drive faster than your guardian angel can fly ...
    but keeping both feet on the ground wont get you anywhere :w00t:

    - How to post Performance Problems
    - How to post data/code to get the best help[/url]

    - How to prevent a sore throat after hours of presenting ppt

    press F1 for solution, press shift+F1 for urgent solution 😀

    Need a bit of Powershell? How about this

    Who am I ? Sometimes this is me but most of the time this is me

  • thank you for that. that is what I figured. i have a task of validating data in my present position and the discrepancy is that, that data field is showing 0 as a value. i sent a response today that the value still shows 0 but they came back with the query i provided, and stating that there is new data. which pretty much, from what i understand from you filters out all the values in the their result that equal 0. which basically means they are filtering out what i am validating against. my advice to everybody is don't go to work at Microsoft.

    A clever person solves a problem. A wise person avoids it. ~ Einstein
    select cast (0x5365616E204465596F756E67 as varchar(128))

  • Oh, and i forgot to mention that i provided them the query i was using to validate with and stated that the 0 values where the discrepancy. They didn't run my query, they created what i provided here. You think maybe i gave them to much information about what the real issue is and gave them the opportunity to contradict and sidetrack my request?

    A clever person solves a problem. A wise person avoids it. ~ Einstein
    select cast (0x5365616E204465596F756E67 as varchar(128))

  • We constantly run into communication problems !

    That's about the biggest challenge of being a DBA :w00t:

    Take a deep breath.

    Now:

    - refrase the question and the answer(s).

    - try to use the language of your target audience. ( Don't say "discrepantie" is "difference" is what they use)

    Avoid the million dollar words. Not everybody is a mathematician or knows Latin. 😉

    Johan

    Learn to play, play to learn !

    Dont drive faster than your guardian angel can fly ...
    but keeping both feet on the ground wont get you anywhere :w00t:

    - How to post Performance Problems
    - How to post data/code to get the best help[/url]

    - How to prevent a sore throat after hours of presenting ppt

    press F1 for solution, press shift+F1 for urgent solution 😀

    Need a bit of Powershell? How about this

    Who am I ? Sometimes this is me but most of the time this is me

  • I provided the script 3 times. I told them strictly/directly as I stated verbally the issue was with that field being of the value 0. There is no confusion. Any possible confusion is they really don't speak English, nor understand script, and I guess that is possible. Seems unlikely though considering they put together and mufti-part condition within a where cause to negate all my effort. When you have been contracting at Microsoft 10 year then you will understand. Your having you fun with me too. You DBA's are all alike, never inspired to be one.

    A clever person solves a problem. A wise person avoids it. ~ Einstein
    select cast (0x5365616E204465596F756E67 as varchar(128))

  • seandeyoung-1145978 (8/5/2010)


    I provided the script 3 times. I told them strictly/directly as I stated verbally the issue was with that field being of the value 0. There is no confusion. Any possible confusion is they really don't speak English, nor understand script, and I guess that is possible. Seems unlikely though considering they put together and mufti-part condition within a where cause to negate all my effort. When you have been contracting at Microsoft 10 year then you will understand. Your having you fun with me too. You DBA's are all alike, never inspired to be one.

    Cool down, I surely didn't want to make fun with you ! (The smylies were only added to freshn up the idea behind, not to mock with your situation)

    Seems to me you're having a very hard time.

    Don't release your steam in a conversation!

    Go out for a walk, hug a tree, hit a boxing bag, ..... do the thing to get rid of this stress.

    Then you can prepare yourself to tackle this situation from another angle.

    We have all been in a situation where we lost hours, days, ... because of misunderstangings. The language barrier is only one of the many.

    p.s. I'm not the kind of guy that gets his right through bluntness. From every situation, something positive can be learned.

    Johan

    Learn to play, play to learn !

    Dont drive faster than your guardian angel can fly ...
    but keeping both feet on the ground wont get you anywhere :w00t:

    - How to post Performance Problems
    - How to post data/code to get the best help[/url]

    - How to prevent a sore throat after hours of presenting ppt

    press F1 for solution, press shift+F1 for urgent solution 😀

    Need a bit of Powershell? How about this

    Who am I ? Sometimes this is me but most of the time this is me

  • Q: How many DBAs does it take to change a light bulb?

    A: "Why do you always wait until the last minute to ask me to push a light bulb into production? This isn't a database issue, anyway."

    A clever person solves a problem. A wise person avoids it. ~ Einstein
    select cast (0x5365616E204465596F756E67 as varchar(128))

  • And afterwards...like most men...he performed a Rollback and never Commited...

    A clever person solves a problem. A wise person avoids it. ~ Einstein
    select cast (0x5365616E204465596F756E67 as varchar(128))

  • He picked those two tables after performing a full scan of the other tables in the room.

    A clever person solves a problem. A wise person avoids it. ~ Einstein
    select cast (0x5365616E204465596F756E67 as varchar(128))

  • Frequent criticism of the DBA staff is that they can be difficult to deal with. Sometimes viewed as a prima donna, DBAs can be curmudgeons who have vast technical knowledge but limited people skills. Just about every database programmer has their favorite DBA story. You know, those famous anecdotes that begin with “I have a problem...” and end with “...and then he told me to stop bothering him and read the manual.”

    A clever person solves a problem. A wise person avoids it. ~ Einstein
    select cast (0x5365616E204465596F756E67 as varchar(128))

  • seandeyoung-1145978 (8/5/2010)


    Frequent criticism of the DBA staff is that they can be difficult to deal with. Sometimes viewed as a prima donna, DBAs can be curmudgeons who have vast technical knowledge but limited people skills. Just about every database programmer has their favorite DBA story. You know, those famous anecdotes that begin with “I have a problem...” and end with “...and then he told me to stop bothering him and read the manual.”

    Been there ... suffered that ... took a chance to alter this behaviour through sound knowledge and openness .... Yes I can ..... again and again ... and again.

    Johan

    Learn to play, play to learn !

    Dont drive faster than your guardian angel can fly ...
    but keeping both feet on the ground wont get you anywhere :w00t:

    - How to post Performance Problems
    - How to post data/code to get the best help[/url]

    - How to prevent a sore throat after hours of presenting ppt

    press F1 for solution, press shift+F1 for urgent solution 😀

    Need a bit of Powershell? How about this

    Who am I ? Sometimes this is me but most of the time this is me

Viewing 13 posts - 1 through 12 (of 12 total)

You must be logged in to reply to this topic. Login to reply