Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
CODE PROJECT For Those Who Code
  • Home
  • Articles
  • FAQ
Community
  1. Home
  2. Database & SysAdmin
  3. Database
  4. [Message Deleted]

[Message Deleted]

Scheduled Pinned Locked Moved Database
24 Posts 6 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • J J4amieC

    Just to get rid of another useless, no-brainer of a post... here you go: // Perfectly workable solution removed, as the OP is an ungrateful gimp. Gives the exact output you needed, with the test code you provided. No warranties or guarantees. Change the names to your actual table names yourself. edit: After reading the above comments, this is the very last time you'll get help from me. edit2: And after reading the below comment, you'll not even get the benefit of this answer.

    modified on Wednesday, October 21, 2009 2:21 PM

    K Offline
    K Offline
    khan2010
    wrote on last edited by
    #15

    see ..!!! Now u are angry..You have to feel this. You have to think twise to tell some one like this " If you're incapable, I suggest you go back to your boss, hand him your keycard and tell him you are not qualified to be a developer. " OK. 1 - and by the way this is wrong answer, what kind of developer you are, each time how can user punch single product name to Check stock, There is million Productname in database. 2 - I just Give you crystal example from my first post. what is in database and what type of output i want, But you didnt understand (No Brain). Lol...I know what type of developer u are i dont need your wrong answer anymore just keep it with you. I will post correct one 2morrow. ''''''''''''

    D J R 3 Replies Last reply
    0
    • K khan2010

      Danish your way to discuss is very good. you understand the fault of my first post. and you mentioned it on very nice way, i understand and thanks to explain me. But i am sorry Danish i just dont like the way of other helps.

      D Offline
      D Offline
      dan sh
      wrote on last edited by
      #16

      khan786 wrote:

      i just dont like the way of other helps

      Well, learn from the mistakes and get over it.

      It's not necessary to be so stupid, either, but people manage it. - Christian Graus, 2009 AD

      1 Reply Last reply
      0
      • K khan2010

        see ..!!! Now u are angry..You have to feel this. You have to think twise to tell some one like this " If you're incapable, I suggest you go back to your boss, hand him your keycard and tell him you are not qualified to be a developer. " OK. 1 - and by the way this is wrong answer, what kind of developer you are, each time how can user punch single product name to Check stock, There is million Productname in database. 2 - I just Give you crystal example from my first post. what is in database and what type of output i want, But you didnt understand (No Brain). Lol...I know what type of developer u are i dont need your wrong answer anymore just keep it with you. I will post correct one 2morrow. ''''''''''''

        D Offline
        D Offline
        dan sh
        wrote on last edited by
        #17

        You do not deserve to be helped. Seriously. A person who wrote code that YOU were supposed to write and instead of being grateful, you are abusing the guy.

        It's not necessary to be so stupid, either, but people manage it. - Christian Graus, 2009 AD

        1 Reply Last reply
        0
        • K khan2010

          see ..!!! Now u are angry..You have to feel this. You have to think twise to tell some one like this " If you're incapable, I suggest you go back to your boss, hand him your keycard and tell him you are not qualified to be a developer. " OK. 1 - and by the way this is wrong answer, what kind of developer you are, each time how can user punch single product name to Check stock, There is million Productname in database. 2 - I just Give you crystal example from my first post. what is in database and what type of output i want, But you didnt understand (No Brain). Lol...I know what type of developer u are i dont need your wrong answer anymore just keep it with you. I will post correct one 2morrow. ''''''''''''

          J Offline
          J Offline
          J4amieC
          wrote on last edited by
          #18

          You, sir, are an anus. Your data model makes this query neigh on impossible to write any other way than that posted above. It is quite simple to adjust what I have given you to pull out the data for one particular product, but i dont remember you requesting this at all. I seriously suggest you seek employment in a less brain-intensive industry. Get used to this phrase "Big mac and fries please".

          K 2 Replies Last reply
          0
          • K khan2010

            [Message Deleted]

            N Offline
            N Offline
            Niladri_Biswas
            wrote on last edited by
            #19

            Try this declare @tbl1 table(productname varchar(20)) insert into @tbl1 values('abc_123a') insert into @tbl1 values('cfl_523j') insert into @tbl1 values('jpm_111k') declare @tbl2 table(productname varchar(20),purqty int) insert into @tbl2 values('abc_123a',50) insert into @tbl2 values('abc_123a',30) insert into @tbl2 values('cfl_523j',100) insert into @tbl2 values('cfl_523j',20) insert into @tbl2 values('cfl_523j',10) insert into @tbl2 values('jpm_111k',105) insert into @tbl2 values('jpm_111k',10) insert into @tbl2 values('jpm_111k',25) declare @tbl3 table(productname varchar(20),soldqty int) insert into @tbl3 values('abc_123a',10) insert into @tbl3 values('abc_123a',05) insert into @tbl3 values('cfl_523j',20) insert into @tbl3 values('cfl_523j',05) insert into @tbl3 values('cfl_523j',10) insert into @tbl3 values('jpm_111k',15) insert into @tbl3 values('jpm_111k',05) insert into @tbl3 values('jpm_111k',10) declare @tbl4 table(productname varchar(20),refqty int) insert into @tbl4 values('abc_123a',2) insert into @tbl4 values('abc_123a',6) insert into @tbl4 values('cfl_523j',4) insert into @tbl4 values('cfl_523j',3) insert into @tbl4 values('cfl_523j',9) insert into @tbl4 values('jpm_111k',3) insert into @tbl4 values('jpm_111k',8) insert into @tbl4 values('jpm_111k',2)

            ;with cte1 as(
            select productname,sum(purqty)as purqty from @tbl2
            group by productname)
            ,cte2 as(
            select productname,sum(soldqty)as soldqty from @tbl3
            group by productname)
            ,cte3 as(
            select productname,sum(refqty)as refqty from @tbl4
            group by productname)

            select c1.productname,c1.purqty,c2.soldqty,c3.refqty,c1.purqty- c2.soldqty-c3.refqty as STOCK
            from cte1 c1 inner join cte2 c2 on c1.productname = c2.productname
            inner join cte3 c3
            on c1.productname = c3.productname

            Let me know in case of any concern :)

            Niladri Biswas

            K 1 Reply Last reply
            0
            • J J4amieC

              You, sir, are an anus. Your data model makes this query neigh on impossible to write any other way than that posted above. It is quite simple to adjust what I have given you to pull out the data for one particular product, but i dont remember you requesting this at all. I seriously suggest you seek employment in a less brain-intensive industry. Get used to this phrase "Big mac and fries please".

              K Offline
              K Offline
              khan2010
              wrote on last edited by
              #20

              J4amieC This is the Correct one Still I am working On it to get some more Correct result, You Brain Less Idiot Look and think your self how u can say you are a developer, and by the way what are you doing here" "U think you can helping people" C ur self in the mirro U Idiot. and learn the manner how to speak with other. ''''''''''''''''''''''''''''''''''''''''''' Just to save time i asked question here. '''''''''''''''''''''''''''''''''''''''''' SELECT Item_Name, (SELECT SUM(Piece_No) AS Quantity FROM Purchase_Detail WHERE (Product.Item_Name = Item)) AS QuantityB, (SELECT SUM(Itm_Qty) AS Quantity FROM Detail_Description WHERE (Product.Item_Name = Item)) AS QuantityC, (SELECT SUM(Itm_Qty) AS Quantity FROM Refund_Detail WHERE (Product.Item_Name = Item_Name)) AS QuantityD, (SELECT SUM(Piece_No) AS Quantity FROM Purchase_Detail AS tblB_1 WHERE (Product.Item_Name = Item)) - (SELECT SUM(Itm_Qty) AS Quantity FROM Detail_Description AS tblC_1 WHERE (Product.Item_Name = Item)) - (SELECT SUM(Itm_Qty) AS Quantity FROM Refund_Detail AS tblD_1 WHERE (Product.Item_Name = Item_Name)) AS Total FROM Product GROUP BY Item_Name

              J 1 Reply Last reply
              0
              • N Niladri_Biswas

                Try this declare @tbl1 table(productname varchar(20)) insert into @tbl1 values('abc_123a') insert into @tbl1 values('cfl_523j') insert into @tbl1 values('jpm_111k') declare @tbl2 table(productname varchar(20),purqty int) insert into @tbl2 values('abc_123a',50) insert into @tbl2 values('abc_123a',30) insert into @tbl2 values('cfl_523j',100) insert into @tbl2 values('cfl_523j',20) insert into @tbl2 values('cfl_523j',10) insert into @tbl2 values('jpm_111k',105) insert into @tbl2 values('jpm_111k',10) insert into @tbl2 values('jpm_111k',25) declare @tbl3 table(productname varchar(20),soldqty int) insert into @tbl3 values('abc_123a',10) insert into @tbl3 values('abc_123a',05) insert into @tbl3 values('cfl_523j',20) insert into @tbl3 values('cfl_523j',05) insert into @tbl3 values('cfl_523j',10) insert into @tbl3 values('jpm_111k',15) insert into @tbl3 values('jpm_111k',05) insert into @tbl3 values('jpm_111k',10) declare @tbl4 table(productname varchar(20),refqty int) insert into @tbl4 values('abc_123a',2) insert into @tbl4 values('abc_123a',6) insert into @tbl4 values('cfl_523j',4) insert into @tbl4 values('cfl_523j',3) insert into @tbl4 values('cfl_523j',9) insert into @tbl4 values('jpm_111k',3) insert into @tbl4 values('jpm_111k',8) insert into @tbl4 values('jpm_111k',2)

                ;with cte1 as(
                select productname,sum(purqty)as purqty from @tbl2
                group by productname)
                ,cte2 as(
                select productname,sum(soldqty)as soldqty from @tbl3
                group by productname)
                ,cte3 as(
                select productname,sum(refqty)as refqty from @tbl4
                group by productname)

                select c1.productname,c1.purqty,c2.soldqty,c3.refqty,c1.purqty- c2.soldqty-c3.refqty as STOCK
                from cte1 c1 inner join cte2 c2 on c1.productname = c2.productname
                inner join cte3 c3
                on c1.productname = c3.productname

                Let me know in case of any concern :)

                Niladri Biswas

                K Offline
                K Offline
                khan2010
                wrote on last edited by
                #21

                Thanks Nildari Biswas for Reply I appreciate for your answer. Thank you very much. But here i solved my problem please check. SELECT Item_Name, (SELECT SUM(Piece_No) AS Quantity FROM Purchase_Detail WHERE (Product.Item_Name = Item)) AS QuantityB, (SELECT SUM(Itm_Qty) AS Quantity FROM Detail_Description WHERE (Product.Item_Name = Item)) AS QuantityC, (SELECT SUM(Itm_Qty) AS Quantity FROM Refund_Detail WHERE (Product.Item_Name = Item_Name)) AS QuantityD, (SELECT SUM(Piece_No) AS Quantity FROM Purchase_Detail AS tblB_1 WHERE (Product.Item_Name = Item)) - (SELECT SUM(Itm_Qty) AS Quantity FROM Detail_Description AS tblC_1 WHERE (Product.Item_Name = Item)) - (SELECT SUM(Itm_Qty) AS Quantity FROM Refund_Detail AS tblD_1 WHERE (Product.Item_Name = Item_Name)) AS Total FROM Product GROUP BY Item_Name again Thanks for reply.

                1 Reply Last reply
                0
                • J J4amieC

                  You, sir, are an anus. Your data model makes this query neigh on impossible to write any other way than that posted above. It is quite simple to adjust what I have given you to pull out the data for one particular product, but i dont remember you requesting this at all. I seriously suggest you seek employment in a less brain-intensive industry. Get used to this phrase "Big mac and fries please".

                  K Offline
                  K Offline
                  khan2010
                  wrote on last edited by
                  #22

                  J4amieC Moron

                  1 Reply Last reply
                  0
                  • K khan2010

                    J4amieC This is the Correct one Still I am working On it to get some more Correct result, You Brain Less Idiot Look and think your self how u can say you are a developer, and by the way what are you doing here" "U think you can helping people" C ur self in the mirro U Idiot. and learn the manner how to speak with other. ''''''''''''''''''''''''''''''''''''''''''' Just to save time i asked question here. '''''''''''''''''''''''''''''''''''''''''' SELECT Item_Name, (SELECT SUM(Piece_No) AS Quantity FROM Purchase_Detail WHERE (Product.Item_Name = Item)) AS QuantityB, (SELECT SUM(Itm_Qty) AS Quantity FROM Detail_Description WHERE (Product.Item_Name = Item)) AS QuantityC, (SELECT SUM(Itm_Qty) AS Quantity FROM Refund_Detail WHERE (Product.Item_Name = Item_Name)) AS QuantityD, (SELECT SUM(Piece_No) AS Quantity FROM Purchase_Detail AS tblB_1 WHERE (Product.Item_Name = Item)) - (SELECT SUM(Itm_Qty) AS Quantity FROM Detail_Description AS tblC_1 WHERE (Product.Item_Name = Item)) - (SELECT SUM(Itm_Qty) AS Quantity FROM Refund_Detail AS tblD_1 WHERE (Product.Item_Name = Item_Name)) AS Total FROM Product GROUP BY Item_Name

                    J Offline
                    J Offline
                    J4amieC
                    wrote on last edited by
                    #23

                    Voted & reported as Abuse

                    1 Reply Last reply
                    0
                    • K khan2010

                      see ..!!! Now u are angry..You have to feel this. You have to think twise to tell some one like this " If you're incapable, I suggest you go back to your boss, hand him your keycard and tell him you are not qualified to be a developer. " OK. 1 - and by the way this is wrong answer, what kind of developer you are, each time how can user punch single product name to Check stock, There is million Productname in database. 2 - I just Give you crystal example from my first post. what is in database and what type of output i want, But you didnt understand (No Brain). Lol...I know what type of developer u are i dont need your wrong answer anymore just keep it with you. I will post correct one 2morrow. ''''''''''''

                      R Offline
                      R Offline
                      Rob Graham
                      wrote on last edited by
                      #24

                      You sir, are a first class jackass.

                      1 Reply Last reply
                      0
                      Reply
                      • Reply as topic
                      Log in to reply
                      • Oldest to Newest
                      • Newest to Oldest
                      • Most Votes


                      • Login

                      • Don't have an account? Register

                      • Login or register to search.
                      • First post
                        Last post
                      0
                      • Categories
                      • Recent
                      • Tags
                      • Popular
                      • World
                      • Users
                      • Groups