Home > database >  Questions about the group by
Questions about the group by

Time:10-05

When is the group by among a set of data has a is not in conformity with the conditions, how to let this group of data is divided into two sections show in is not in conformity with the conditions there?

CodePudding user response:

The SQL statement is:

SELECT
Min (cardno) mincard,
Max (cardno) maxcard,
Case card_giveout_status when '0' then 'not paid' when '1' then 'issued' end card_giveout_status,
Case card_make_status when '0' then 'not' when '1' then 'has been produced' when '2' then 'made in' end card_make_status,
Card_make_batch,
DATE_FORMAT (card_add_time, '% Y - % m % d - % T') as card_add_time,
DATE_FORMAT (card_giveout_time, '% Y - % m % d - % T') as card_giveout_time,
DATE_FORMAT (card_make_time, '% Y - % m % d - % T') as card_make_time
The FROM
(
SELECT
Card_giveout_status,
Card_make_status,
Card_make_batch,
Cardno,
Card_add_time,
Card_giveout_time,
Card_make_time,
Cardno - (@ rownum:=@ rownum + 1) AS cardrn
The FROM
Card_base c,
R: (SELECT @ rownum=0)
The ORDER BY
Cardno
) AS cardtype
GROUP BY
Cardtype card_make_batch, cardtype card_make_status, cardtype. Card_giveout_status, cardtype. Cardrn

CodePudding user response:

The result is:

888885000021, 888885000199 did not issue not
888885000000 has been produced 1477541864468 issued 888885000000
888885000003, 888885000003 did not issue has made 1477541876774
888885000001 has been produced 1477541876774 issued 888885000002
888885000004, 888885000006 did not issue has made 1477548666683
888885000007 to 888885000008 issued in 1477548666683
888885000009, 888885000009 did not issue has made 1477548859891
888885000015 has been produced 1477548859891 issued 888885000015
888885000010, 888885000020, issued in 1477548859891

CodePudding user response:

Is there a god? Online, wait ~ ~ ~

CodePudding user response:

Didn't understand the meaning,,,, it is suggested that posted on the original data, and then posted on the data you want

CodePudding user response:

The original results issued 888885000015, 888885000015 has been produced 1477548859891
888885000010 to 888885000020 issued in 1477548859891
The
888885000010, 888885000014, issued in 1477548859891

CodePudding user response:

The original results
888885000015 has been produced 1477548859891 issued 888885000015
888885000010 to 888885000020 issued in 1477548859891
The
888885000010 to 888885000014 issued in 1477548859891
888885000015 has been produced 1477548859891 issued 888885000015
888885000016, 888885000020, issued in 1477548859891

CodePudding user response:

Still didn't understand,,, the result is what kind of do you want

CodePudding user response:

The building Lord, you use excel to draw two diagrams, a said the raw data, a said about the result you want;

CodePudding user response:

Technical skills is one thing, the ability is another matter

CodePudding user response:

references 9 f jdsnhan response:
technical ability is one thing, the expression ability is another matter
expressed everybody can suit the remedy to the case
  • Related