Go Back   TechArena Community > Software > Software Development
Become a Member!
Forgot your username/password?
Tags Active Topics RSS Search Mark Forums Read

Reply
 
Thread Tools Search this Thread
  #1  
Old 07-05-2009
Member
 
Join Date: Mar 2009
Posts: 175
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?
Reply With Quote
  #2  
Old 07-05-2009
XSI XSI is offline
Member
 
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 ...
Reply With Quote
  #3  
Old 07-05-2009
Member
 
Join Date: May 2008
Posts: 2,383
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"
__________________
The FIFA Manager 2009 PC Game
Reply With Quote
  #4  
Old 07-05-2009
XSI XSI is offline
Member
 
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 ...
Reply With Quote
  #5  
Old 07-05-2009
Member
 
Join Date: Mar 2009
Posts: 175
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.
Reply With Quote
Reply

  TechArena Community > Software > Software Development
Tags: ,



Thread Tools Search this Thread
Search this Thread:

Advanced Search


Similar Threads for: "Problem with group by 3 letters"
Thread Thread Starter Forum Replies Last Post
Problem Applying WMI Filter to Group Policy Max-well Windows Software 5 24-08-2010 03:14 AM
Add domain user\group to local admin group problem Landon Active Directory 3 16-10-2009 09:30 PM
Drive letters problem while cloning 2003 server mdnchauhan Operating Systems 2 19-09-2008 06:38 PM
Changing small letters back to proper Capital letters in .doc rEDNESS TroubleShoot 98 2 04-03-2008 09:50 PM
Group Policy My Documents Redirection Problem Lynette Small Business Server 3 30-01-2008 01:46 AM


All times are GMT +5.5. The time now is 03:10 AM.