Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9065503
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T16:31:03+00:00 2026-06-16T16:31:03+00:00

Anybody can convert this query to active record codeigniter??? SELECT b.name, SUM(CASE WHEN c.size

  • 0

Anybody can convert this query to active record codeigniter???

 SELECT  b.name,
    SUM(CASE WHEN c.size = 'S' THEN 1 ELSE 0 END) S,
    SUM(CASE WHEN c.size = 'M' THEN 1 ELSE 0 END) M,
    SUM(CASE WHEN c.size = 'L' THEN 1 ELSE 0 END) L,
    SUM(CASE WHEN c.size = 'XL' THEN 1 ELSE 0 END) XL
   FROM    orderTB a
    INNER JOIN productTB b
        ON a.id_product = b.id_shirt
    INNER JOIN sizeTB c
        ON a.id_size = c.id_size
GROUP BY b.name

i’ve tried like this

  function get()
 {
  $this->db->select("b.name,SUM(CASE WHEN c.size ='S' THEN 1 ELSE 0 END) as S,SUM(CASE    WHEN c.size = 'M' THEN 1 ELSE 0 END) as M,SUM(CASE WHEN c.size = 'L' THEN 1 ELSE 0 END) as   L,SUM(CASE WHEN c.size = 'XL' THEN 1 ELSE 0 END) as XL");

 $this->db->from('order');
 $this->db->join('ukuran','order.id_size=ukuran.id_size');
 $this->db->where('date',$date);
 return $this->db->get();
 }

but its wrong

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-16T16:31:05+00:00Added an answer on June 16, 2026 at 4:31 pm

    Just try this one and let me know,

    $this->db->select("b.name,SUM(CASE WHEN c.size = 'S' THEN 1 ELSE 0 END) S,SUM(CASE WHEN c.size = 'M' THEN 1 ELSE 0 END) M,SUM(CASE WHEN c.size = 'L' THEN 1 ELSE 0 END) L,SUM(CASE WHEN c.size = 'XL' THEN 1 ELSE 0 END) XL", FALSE );
    $this->db->from('orderTB a');
    $this->db->join('productTB b','a.id_product = b.id_shirt','inner');
    $this->db->join('sizeTB c','a.id_size = c.id_size','inner');
    $this->db->group_by('b.name');
    

    From document here

    $this->db->select() accepts an optional second parameter. If you set
    it to FALSE, CodeIgniter will not try to protect your field or table
    names with backticks. This is useful if you need a compound select
    statement.

    EDIT

    Just add FALSE in your select statement

    function get() {
        $this->db->select("b.name,SUM(CASE WHEN c.size ='S' THEN 1 ELSE 0 END) as S,SUM(CASE    WHEN c.size = 'M' THEN 1 ELSE 0 END) as M,SUM(CASE WHEN c.size = 'L' THEN 1 ELSE 0 END) as   L,SUM(CASE WHEN c.size = 'XL' THEN 1 ELSE 0 END) as XL",FALSE);
    
        $this->db->from('order');
        $this->db->join('ukuran','order.id_size=ukuran.id_size');
        $this->db->where('date',$date);
        return $this->db->get();
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Hello everyone can anybody please help me to convert this sql to linq I
How to convert Object to List. Can anybody tell me how to fix this
When I write this query SELECT Convert(datetime,Convert(varchar,CAST(GETUTCDATE() AS DATE))+' '+ CONVERT(varchar, cast(meas_pain.datetime AS time)))
Can anybody give an example of c++ code that can easily convert a decimal
Can any body help me to convert the following SQL query in LinqToSql syntax.
I have this code in Linq. Anybody can provide the t-sql. thanks! var tsr
Can anybody please tell me why the removeEventListener call is not working? this.addEventListener(Event.ENTER_FRAME, eventCall,
string s= Name nnnn Age dd </tr> </table> I need to convert this string
Does anybody invent a workable converter program that can convert XHTML file to FlowDocument
can anybody spot any mistake in this function? .. This is a function which

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.