Group by problem

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • seralasu
    New Member
    • Oct 2006
    • 34

    #1

    Group by problem

    I have a problem about group by. My database name ayniyat_x and it has 6 fields.
    FIELDS
    hesap_kodu duzey_1 duzey_2 duzey_3 duzey_4 duzey_5
    150 01 01 01 25 null
    150 02 01 05
    150 01 01 24
    253 01 01 19
    150 02 01 16

    What I explain How I can be group same fields hesap_kodu,duze y_1,duzey_2
    150 01 01 01 25
    150 01 01 24
    150 02 01 05
    150 02 01 16
    253 01 01 19

    I tried tgis sql but it didn't work.
    "Select * from ayniyat_x where (hesap_kodu,duz ey_1,duzey_2) in (select * from ayniyat_x group by hesap_kodu,duze y_1,duzey_2)
  • mklprasanna
    New Member
    • Apr 2007
    • 10

    #2
    Hi,
    if you have same values in hesap_kodu,duze y_1,duzey_2 these fileds then you can write query like this

    Select * from ayniyat_x group by hesap_kodu,duze y_1,duzey_2;

    then you will get one record which is having the same data for all fileds.

    For example.
    hesap_kodu duzey_1 duzey_2
    1 1 1
    2 1 1
    1 1 2
    1 2 1
    1 1 1
    for this example we get one record.bcz 1st and last records have the same data.


    I think it was clear!!

    prasanna

    Comment

    • seralasu
      New Member
      • Oct 2006
      • 34

      #3
      Originally posted by mklprasanna
      Hi,
      if you have same values in hesap_kodu,duze y_1,duzey_2 these fileds then you can write query like this

      Select * from ayniyat_x group by hesap_kodu,duze y_1,duzey_2;

      then you will get one record which is having the same data for all fileds.

      For example.
      hesap_kodu duzey_1 duzey_2
      1 1 1
      2 1 1
      1 1 2
      1 2 1
      1 1 1
      for this example we get one record.bcz 1st and last records have the same data.


      I think it was clear!!

      prasanna

      Hi,
      I didn't understand what you said. "We get one record.bcz 1st and last records have the same data." If you explain, I am happy.

      Comment

      • mklprasanna
        New Member
        • Apr 2007
        • 10

        #4
        Originally posted by seralasu
        Hi,
        I didn't understand what you said. "We get one record.bcz 1st and last records have the same data." If you explain, I am happy.
        Hi,

        Select * from ayniyat_x group by hesap_kodu,duze y_1,duzey_2;

        In this query we are using group by clause and the records are grouped based on these hesap_kodu,duze y_1,duzey_2 three values.and that to these three values should be same.

        Thats what i am saying,With the example.

        I think it was clear now!!!

        Comment

        • prashanth023
          New Member
          • Apr 2007
          • 13

          #5
          prasanna,
          I am also observing thsi problem can u explain clear

          Comment

          • prashanth023
            New Member
            • Apr 2007
            • 13

            #6
            Ya prasanna. I got it. thanks. i also need this.

            Comment

            Working...