Results 1 to 4 of 4
  1. #1
    Join Date
    Dec 2003
    Posts
    5

    Unanswered: Querying different strings

    Hy...

    I want to know how much different strings there are in my table ?

    Let me explain...

    I have a table lokking like this :

    sessionid - varchar(128)
    ipaddr - varchar(21)
    ipname - varchar(256)
    log - varchar(1024)

    Now there are a few rows of this table

    1234abcd1234 1.1.1.127:82 myhost.com "what have i done"
    1234abcd1234 1.1.1.127:82 myhost.com "did something"
    1234abcd1234 1.1.1.127:82 myhost.com "logged out"
    4321abcd4321 1.1.1.127:82 myhost.com "another log in"
    5678abcd5678 4.4.4.121:88 otherhost.com "what have i done"

    Now I want to know how much sessions there are in this table.

    How can I query how much different sessionids (maybe in connect with ipaddr) there are ?
    And how can I get the number of the entrys of each sessionid ?

    The example above should show

    3 (different sessionids) for counting the sessions.

    And
    1 3
    1 1
    1 1
    for the detail of how much has been done in each session.


    Help would be appreciated...

    Mfg
    Thomas

  2. #2
    Join Date
    Sep 2003
    Location
    The extremely Royal borough of Kensington, London
    Posts
    778
    select distinct t.session_id,
    (select count(*) from table where session_id = t.session_id) As "Count"
    from table;
    Bessie Braddock: Winston, you are drunk!
    Churchill: And Madam, you are ugly. And tomorrow, I'll be sober, and you will still be ugly.

  3. #3
    Join Date
    Dec 2003
    Posts
    5
    Originally posted by r123456
    select distinct t.session_id,
    (select count(*) from table where session_id = t.session_id) As "Count"
    from table;
    Works fine for only session_id but how can this be done for 2 fields.

    session_id would be the same and ipaddr (username) has changed.

    sessionid idaddr log
    123abc123 myaddr logon
    123abc123 myaddr dosomething
    123abc123 my2ndaddr logon
    321abc321 myaddr logon

    How can this be done ???

    select distinct session_id from table
    would only return 2 rows. But there should be 3 rows.

    Any idea ???

    Bye
    Thomas

  4. #4
    Join Date
    Sep 2003
    Location
    The extremely Royal borough of Kensington, London
    Posts
    778
    select s.session_id, s.ip_address, count(*)
    from session_info s
    group by s.session_id, s.ip_address
    Bessie Braddock: Winston, you are drunk!
    Churchill: And Madam, you are ugly. And tomorrow, I'll be sober, and you will still be ugly.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •