Loading ...
Sorry, an error occurred while loading the content.

Re: [SQLQueriesNoCode] SQL If statement????

Expand Messages
  • Muhammad Ahmed
    hi, This is what I understand from your point. If I mis-understand or my point is not very clear then let me know and clarify your case with the example: I
    Message 1 of 9 , Aug 1 12:06 AM
    • 0 Attachment
      hi,

      This is what I understand from your point. If I mis-understand or my point
      is not very clear then let me know and clarify your case with the example:

      I think you wanna result set; if Table A does not contain the reference then
      you want it to replace it with some other field.

      Now you can check it with the count of the result set and if count is zero
      then you can return the default values and if count is 1 or greater then you
      can return the actual values.

      You can always refer to the TSQL help from Query Analyzer if you are new to
      T-SQL.

      Regards,
      Muhammad Ahmed

      On 7/31/07, sjcwhittle <sjcwhittle@...> wrote:
      >
      > Very new to sql - but I am trying to bascially use a function similar
      > to the if s'tmt in excel.
      >
      > Bascially the If st'mt will query Table A - but my problem is if the
      > ref I am looking up is not in table A, I want to replace it with a
      > default field rather than jsut not including it????
      >
      > Is this possible?
      >
      >
      >
      >
      > Yahoo! Groups Links
      >
      >
      >
      >


      --
      Regards,

      Muhammad Ahmed


      [Non-text portions of this message have been removed]
    • srussell@lotmate.com
      ... Try either CASE or ISNULL for T-SQL substitutions as needed.
      Message 2 of 9 , Aug 1 8:11 AM
      • 0 Attachment
        > hi,
        >
        > This is what I understand from your point. If I mis-understand or my point
        > is not very clear then let me know and clarify your case with the
        > example:
        >
        > I think you wanna result set; if Table A does not contain the reference
        > then
        > you want it to replace it with some other field.
        >
        > Now you can check it with the count of the result set and if count is zero
        > then you can return the default values and if count is 1 or greater then
        > you
        > can return the actual values.



        Try either CASE or ISNULL for T-SQL substitutions as needed.
      • sjcwhittle
        Hi - Thankyou for the help basically I have a query that is looking for say X in table 1. If X is in table one, all is good. If it is not, I want the query to
        Message 3 of 9 , Aug 1 10:51 AM
        • 0 Attachment
          Hi - Thankyou for the help

          basically I have a query that is looking for say X in table 1.

          If X is in table one, all is good. If it is not, I want the query to
          populate a Y. Is this possible?








          --- In SQLQueriesNoCode@yahoogroups.com, srussell@... wrote:
          >
          > > hi,
          > >
          > > This is what I understand from your point. If I mis-understand
          or my point
          > > is not very clear then let me know and clarify your case with
          the
          > > example:
          > >
          > > I think you wanna result set; if Table A does not contain the
          reference
          > > then
          > > you want it to replace it with some other field.
          > >
          > > Now you can check it with the count of the result set and if
          count is zero
          > > then you can return the default values and if count is 1 or
          greater then
          > > you
          > > can return the actual values.
          >
          >
          >
          > Try either CASE or ISNULL for T-SQL substitutions as needed.
          >
        • srussell@lotmate.com
          ... Here is how to use CASE Plenty to pick from.
          Message 4 of 9 , Aug 1 11:16 AM
          • 0 Attachment
            > Hi - Thankyou for the help
            >
            > basically I have a query that is looking for say X in table 1.
            >
            > If X is in table one, all is good. If it is not, I want the query to
            > populate a Y. Is this possible?

            Here is how to use CASE <http://tinyurl.com/2wzmry> Plenty to pick from.
          • Stephen Russell
            What have you tried? You have to supply something for your code base and we will help you finish it. Just telling us what you want us to do for you, well I m
            Message 5 of 9 , Aug 4 6:46 PM
            • 0 Attachment
              What have you tried? You have to supply something for your code base and we
              will help you finish it. Just telling us what you want us to do for you,
              well I'm sorry but your not learning anything. You have to show some of
              your work.




              Stephen Russell
              DBA / .Net Developer

              Memphis TN 38115
              901.246-0159

              "A good way to judge people is by observing how they treat those who can do
              them absolutely no good."
              ---Unknown

              HYPERLINK
              "http://spaces.msn.com/members/srussell/"http://spaces.msn.com/members/sruss
              ell/



              _____

              From: SQLQueriesNoCode@yahoogroups.com
              [mailto:SQLQueriesNoCode@yahoogroups.com] On Behalf Of sjcwhittle
              Sent: Wednesday, August 01, 2007 12:51 PM
              To: SQLQueriesNoCode@yahoogroups.com
              Subject: [SQLQueriesNoCode] Re: SQL If statement????



              Hi - Thankyou for the help

              basically I have a query that is looking for say X in table 1.

              If X is in table one, all is good. If it is not, I want the query to
              populate a Y. Is this possible?

              --- In HYPERLINK
              "mailto:SQLQueriesNoCode%40yahoogroups.com"SQLQueriesNoCode@-yahoogroups.-co
              m, srussell@... wrote:
              >
              > > hi,
              > >
              > > This is what I understand from your point. If I mis-understand
              or my point
              > > is not very clear then let me know and clarify your case with
              the
              > > example:
              > >
              > > I think you wanna result set; if Table A does not contain the
              reference
              > > then
              > > you want it to replace it with some other field.
              > >
              > > Now you can check it with the count of the result set and if
              count is zero
              > > then you can return the default values and if count is 1 or
              greater then
              > > you
              > > can return the actual values.
              >
              >
              >
              > Try either CASE or ISNULL for T-SQL substitutions as needed.
              >






              No virus found in this incoming message.
              Checked by AVG Free Edition.
              Version: 7.5.476 / Virus Database: 269.11.0/929 - Release Date: 7/31/2007
              5:26 PM



              No virus found in this outgoing message.
              Checked by AVG Free Edition.
              Version: 7.5.476 / Virus Database: 269.11.4/935 - Release Date: 8/3/2007
              5:46 PM



              [Non-text portions of this message have been removed]
            Your message has been successfully submitted and would be delivered to recipients shortly.