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 9301867
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T23:07:40+00:00 2026-06-18T23:07:40+00:00

This is the sql fiddle : http://sqlfiddle.com/#!2/e6acc/4 And it shows the right result since

  • 0

This is the sql fiddle :http://sqlfiddle.com/#!2/e6acc/4

And it shows the right result since I want the duplicate entries to be enumerated.

But when I run in on mysql/phpmyadmin, the result is this:

1515    Abdominal
1100    Hep B Inj Fee
40  1-Ligation
40  1-Ligation
900 1-Suturing Fee
900 1-Suturing Fee
900 1-Suturing Fee
900 1-Suturing Fee

It’s all 1. I already restarted my pc. and its still the same. Why is that? I just retrieved the csv tables from my mysql to the fiddle.

edit:
Ok this is getting weirder. On my front-end, its working when I view other ID’s:
enter image description here

But still, when I change the id on my query and enter in on phpmyadmin, it stil shows 1.

  • 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-18T23:07:41+00:00Added an answer on June 18, 2026 at 11:07 pm

    I don’t have any idea why the SQL Fiddle is different than the actual result, but I managed to make it work for me in PHP. Use the following query:

    SELECT
      c.procno,
      CONCAT(CASE WHEN cnt > 1 THEN CONCAT(RN,'-') ELSE '' END, t.Proc) Proc
    FROM
      (
        SELECT
          @curRow:=CASE WHEN @prevRow = a.Proc THEN @curRow+1 ELSE 1 END AS rn,
          a.Proc,
          a.Procno,
          @prevRow:=Proc grp
        FROM (    
              SELECT
                `incurredcharges`.`procedure_no` procno,
                `c`.`procedure` proc
              FROM
                incurredcharges
                INNER JOIN (
                  SELECT `procedure`, `procedure_no` FROM `charges`
                  UNION ALL
                  SELECT `confinement`, `procedure_no` FROM `confinement`
                  UNION ALL
                  SELECT `service`, `procedure_no` FROM `ultrasound`
                ) c ON `incurredcharges`.`procedure_no` = c.`procedure_no`
              WHERE `incurredcharges`.`patient_no` = '34'
              ORDER BY `c`.`procedure`
          ) a 
              JOIN (SELECT @curRow:=0, @prevRow:= '') r
      ) t JOIN
      (
              SELECT
                `incurredcharges`.`procedure_no` procno,
                `c`.`procedure` proc, Count(*) cnt
              FROM
                incurredcharges
                INNER JOIN (
                  SELECT `procedure`, `procedure_no` FROM `charges`
                  UNION ALL
                  SELECT `confinement`, `procedure_no` FROM `confinement`
                  UNION ALL
                  SELECT `service`, `procedure_no` FROM `ultrasound`
                ) c ON `incurredcharges`.`procedure_no` = c.`procedure_no`
              WHERE `incurredcharges`.`patient_no` = '34'
              GROUP BY `incurredcharges`.`procedure_no`,
                `c`.`procedure`
      ) c ON t.proc = c.proc
    

    The only thing I changed was line 27 from JOIN (SELECT @curRow:=0) r to JOIN (SELECT @curRow:=0, @prevRow:= '') r

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have 3 tables and I want to join it. Check this fiddle: http://sqlfiddle.com/#!2/20410/2
Take a look at this fiddle: http://sqlfiddle.com/#!6/18324/2 Expand the very first execution plan, for
Following in my sql fiddle: http://sqlfiddle.com/#!2/62429/2 I have a username , which i need
I have this database setup: http://sqlfiddle.com/#!12/b2989 I want to add a record called solrID
SQL Fiddle: http://sqlfiddle.com/#!3/9b459/6 I have a table containing answers to the question Will you
Check this example before reading the question - http://www.sqlfiddle.com/#!2/fcf3e/8 The following data comes from
This sqlfiddle link seems to retain state across invocations: http://sqlfiddle.com/#!2/125bc/1 It contains this schema
Can someone help explain this to me and resolve it? http://sqlfiddle.com/#!6/2adc7/9 The INSERT statement
I got this example to work with some help on here: http://sqlfiddle.com/#!2/92e87/1 However, if
I'm trying to do this: http://sqlfiddle.com/#!2/a13fc/2 . I'm getting the rror Illegal mix of

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.