SitePoint Sponsor

User Tag List

Results 1 to 7 of 7
  1. #1
    SitePoint Enthusiast Rami Yacoub's Avatar
    Join Date
    Oct 2004
    Location
    jordan
    Posts
    32
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Question how can i get sum from 2 table???

    hi every body,
    i have 2 table daily , and region
    daily contain,
    - id
    -region (fk)
    -data
    -views
    -item

    region table contain
    -id
    -name.

    i wana make a query or multible querys that fetch the sum of views to the region.name which name contain 'jo' and 'lb' ??

    :'( :'( :'( :'(
    any body can help me a

  2. #2
    SQL Consultant gold trophysilver trophybronze trophy
    r937's Avatar
    Join Date
    Jul 2002
    Location
    Toronto, Canada
    Posts
    39,341
    Mentioned
    63 Post(s)
    Tagged
    3 Thread(s)
    Code:
    select r.name
         , sum(d.views) as sumviews
      from region as r
    left outer
      join daily as d
        on r.id = d.region
     where r.name like '%jo%' 
       and r.name like '%lb%'
    group
        by r.name
    rudy.ca | @rudydotca
    Buy my SitePoint book: Simply SQL
    "giving out my real stuffs"

  3. #3
    SitePoint Enthusiast Rami Yacoub's Avatar
    Join Date
    Oct 2004
    Location
    jordan
    Posts
    32
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    it's ok

    thanks ,
    but i want it between 01-01-2004 to 01-01-2005;
    and i try to update the %jo% to %-jo but noting good happend
    so plz help me

  4. #4
    SQL Consultant gold trophysilver trophybronze trophy
    r937's Avatar
    Join Date
    Jul 2002
    Location
    Toronto, Canada
    Posts
    39,341
    Mentioned
    63 Post(s)
    Tagged
    3 Thread(s)
    Quote Originally Posted by Rami Yacoub
    but i want it between 01-01-2004 to 01-01-2005
    but that's not what you asked for!

    what is the purpose of jo and lb? do you want region.name to contain those characters or not?

    and which column has the dates in it?
    rudy.ca | @rudydotca
    Buy my SitePoint book: Simply SQL
    "giving out my real stuffs"

  5. #5
    SitePoint Enthusiast Rami Yacoub's Avatar
    Join Date
    Oct 2004
    Location
    jordan
    Posts
    32
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    sorry

    thanks ,
    but they ask me 2 updata my query, sorry for that
    the data in the daily table..
    :'(

  6. #6
    SQL Consultant gold trophysilver trophybronze trophy
    r937's Avatar
    Join Date
    Jul 2002
    Location
    Toronto, Canada
    Posts
    39,341
    Mentioned
    63 Post(s)
    Tagged
    3 Thread(s)
    Code:
    select r.name
         , sum(d.views) as sumviews
      from region as r
    left outer
      join daily as d
        on r.id = d.region
       and d.data between '2004-01-01' and '2005-01-01'
    group
        by r.name
    rudy.ca | @rudydotca
    Buy my SitePoint book: Simply SQL
    "giving out my real stuffs"

  7. #7
    SitePoint Enthusiast Rami Yacoub's Avatar
    Join Date
    Oct 2004
    Location
    jordan
    Posts
    32
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    thans alot

    Thanks A lot


    u r


Bookmarks

Posting Permissions

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