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

  • SEARCH
  • Home
  • 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 6468231
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T05:52:14+00:00 2026-05-25T05:52:14+00:00

I have a problem with the request below! REQUEST: SELECT COALESCE(date(date_field), ‘Total’) AS date_field_group,

  • 0

I have a problem with the request below!

REQUEST:

SELECT COALESCE(date(date_field), 'Total') AS "date_field_group",
COUNT( id_field ) AS  "Nombre de bookings",
CONCAT( REPLACE( REPLACE( FORMAT( SUM( price1 ) , 2 ) , ',',  ' ' ) ,  '.',  ',' ) ,  ' €' ) AS  "Total à l'achat",
CONCAT( REPLACE( REPLACE( FORMAT( SUM( price2 ) , 2 ) ,  ',',  ' ' ) ,  '.',  ',' ) ,  ' €' ) AS  "Total à la vente",
CONCAT( REPLACE( REPLACE( FORMAT( SUM( price2 ) - SUM( price1 ) , 2 ) ,  ',',  ' ' ) ,  '.',  ',' ) ,  ' €' ) AS  'Marge',
CONCAT( REPLACE( FORMAT( (SUM( price2 ) / SUM( price1 ) ) , 2 ) ,  '1.',  '' ) ,  ' ',  '%') AS  "Markup moyen"
FROM table1 S, table2 B
WHERE status_field
IN ( "1",  "5")
AND DATE( date_field ) BETWEEN  "2011-08-01" AND  "2011-08-31"
AND type_field =  "H"
AND price1 IS NOT NULL 
AND S.id_field = B.id_field
AND B.id2 =  "1"
GROUP BY date_field_group WITH ROLLUP

The thing is that the request is working fine (right numbers), but in the last line I was expected to get in first row “Total” and instead of that I got a field NULL…

Is someone know what is wrong with my request ?
Thx for any help ;).

  • 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-05-25T05:52:14+00:00Added an answer on May 25, 2026 at 5:52 am

    You’re query is almost correct (except for using implicit SQL ’89 joins, which is an SQL anti-pattern)

    The problem is in the last line: GROUP BY ... WITH ROLLUP.
    The rollup gets applied very late in the process, after your COALESCE(date(date_field), 'Total').
    So the coalesce has already finished by the time rollup comes along you need to rewrite the query like so:

    SELECT COALESCE(date_field_group, 'Total') as date_field_group
      , `Nombre de bookings`
      , `Total à l'achat`
      , `Total à la vente`
      , `Marge`
      , `Markup moyen`
    FROM (
       SELECT date(date_field) AS "date_field_group",   
         COUNT( id_field ) AS  "Nombre de bookings",   
         CONCAT( REPLACE( REPLACE( FORMAT( SUM( price1 ) , 2 ) , ',',  ' ' ) ,  '.',  ',' ) ,  ' €' ) AS  "Total à l'achat",   
         CONCAT( REPLACE( REPLACE( FORMAT( SUM( price2 ) , 2 ) ,  ',',  ' ' ) ,  '.',  ',' ) ,  ' €' ) AS  "Total à la vente",   
        CONCAT( REPLACE( REPLACE( FORMAT( SUM( price2 ) - SUM( price1 ) , 2 ) ,  ',',  ' ' ) ,  '.',  ',' ) ,  ' €' ) AS  'Marge',   
        CONCAT( REPLACE( FORMAT( (SUM( price2 ) / SUM( price1 ) ) , 2 ) ,  '1.',  '' ) ,  ' ',  '%') AS  "Markup moyen"   
      FROM table1 S
      INNER JOIN table2 B ON (S.id_field = B.id_field)   
      WHERE status_field IN ( "1",  "5")   
        AND DATE( date_field ) BETWEEN  "2011-08-01" AND  "2011-08-31"   
        AND type_field =  "H"   
        AND price1 IS NOT NULL    
        AND B.id2 =  "1"   
      GROUP BY date_field_group WITH ROLLUP ) AS subquery
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am using VB.NET My problem is that, I have got below request.querystring http://localhost/ISS/Training/TrainingUpdate.aspx?cpuserid='50'&%20courseid='6'&%20status='accept'
I have a problem. I built a script to make a request to an
I have the next problem: I need to process only 1 request at a
I am using the below example code and have a problem where I can't
I have a problem creating authentication part for my application. Below is the simplified
I have file writing permission denied problem in my web application, below is the
I have the same problem as below: ASP.NET MVC 3 ValidateRequest(false) not working with
I have a code as below import flash.media.Sound; import flash.media.SoundChannel; flash.system.Security.allowDomain(*); var request:URLRequest =
Below is the full log, the problem is in 23 dd.append(str(msg.get_json())) I have some
I have no problem to run the sample code below in a iPhone simulator,

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.