Results 1 to 5 of 5

Thread: Problem with group by 3 letters

  1. #1
    Join Date
    Mar 2009
    Posts
    176

    Problem with group by 3 letters

    I made a query and took all customers_from starting with first and grouped but my problem is that I want to do the same thing but on all the fields customers_from

    For example, I have the following names in my fields:

    1st_qwe, 1st_asd, 1st_ghj, 1st_poi, add_qwe, add_rtz, add_lkj, add_puz, poi_ghj, poi_gjhgj, poi_tgb etc...

    So I'd like to take the three letter and condition like that

    Code:
    SELECT IF (customers_from LIKE '1st%','1rst',customers_from) AS Origin, 
    COUNT (cu.customers_id) AS effectif_vg 
    FROM en_customers cu INNER JOIN en_commands co on cu.customers_id = co.customers_id 
    WHERE customers_free ='1' 
    GROUP BY Origin"
    Is there a solution to my problem?

  2. #2
    Join Date
    May 2008
    Posts
    271

    Re: Problem with group by 3 letters

    If you make a complaint in this:

    SELECT
    LEFT (cu.customers_from, 3) as origin,
    COUNT (cu.customers_id) AS effectif_vg
    FROM en_customers cu
    INNER JOIN en_commands co on cu.customers_id = co.customers_id
    WHERE ***co or cu ??? *** .customers_free = '1'
    GROUP BY LEFT (cu.customers_from, 3)

    Must not operate?

    For against, I do not know what it is if you have customers_from who have a length <3, on MySQL, it still includes ...

  3. #3
    Join Date
    May 2008
    Posts
    2,389

    Re: Problem with group by 3 letters

    With Oracle and other DBMS, you can use substr (field, index_of_depart_starting_a_1, length), giving

    SELECT substr (customers_from, 1, 3) as origin,
    COUNT (cu.customers_id) AS effectif_vg
    FROM en_customers cu INNER JOIN en_commands co on cu.customers_id = co.customers_id
    WHERE customers_free ='1 '
    GROUP BY Origin"

  4. #4
    Join Date
    May 2008
    Posts
    271

    Re: Problem with group by 3 letters

    Ok, the substr seems a little more generic, I'm used to left or right, in MySQL, you can make the 2 with the same result ...

  5. #5
    Join Date
    Mar 2009
    Posts
    176

    Re: Problem with group by 3 letters

    Thank you but my problem is that I wanted to see more of origin (which are not affected by the combination) but I think it's impossible.

Similar Threads

  1. Problem Applying WMI Filter to Group Policy
    By Max-well in forum Windows Software
    Replies: 5
    Last Post: 24-08-2010, 03:14 AM
  2. Add domain user\group to local admin group problem
    By Landon in forum Active Directory
    Replies: 3
    Last Post: 16-10-2009, 09:30 PM
  3. Drive letters problem while cloning 2003 server
    By mdnchauhan in forum Operating Systems
    Replies: 2
    Last Post: 19-09-2008, 06:38 PM
  4. Replies: 2
    Last Post: 04-03-2008, 09:50 PM
  5. Group Policy My Documents Redirection Problem
    By Lynette in forum Small Business Server
    Replies: 3
    Last Post: 30-01-2008, 01:46 AM

Tags for this Thread

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
  •  
Page generated in 1,713,575,512.49600 seconds with 17 queries