473,473 Members | 1,988 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Sequence of rows

263 Contributor
Hello everyone;

In the table MYSQL I have this sequence of rows:

CODE===========NAME
610=============ASS
610=============ASS
610=============ASS
610=============ASS
619=============ASS-9
619=============ASS-9
619=============ASS-9

I like to see:

ASS

and query that counts for all rows like ASS...

Can you help me ?
Regards
Apr 24 '08 #1
8 1829
deric
92 New Member
Is the value ASS fix?
Try any of these...
Expand|Select|Wrap|Line Numbers
  1. select distinct name, count(name) from table where name = 'ASS' 
  2. /*will result to:
  3. ASS, 4 */
  4.  
  5. select distinct name, count(name) from table 
  6. /*will result to:
  7. ASS, 4
  8. ASS-9, 3*/
  9.  
  10. select distinct name count(name) from table where name like 'ASS%'
  11. /*will result to:
  12. ASS, 4
  13. ASS-9, 3*/
Apr 25 '08 #2
viki1967
263 Contributor
Many thanks Deric for your reply.

First I write you one example.

The real situation in the table mysql is:

9168383 510 >>>>> DTR SAR-ZO OR-UOS ORISTANO
9168383 519 >>>>> DTR SAR-ZO OR-UOS ORISTANO-9
9168383 110 >>>>> DTR SAR-ZO OR-PRG-PROGRAM.OPERATIVA
9168383 119 >>>>> DTR SAR-ZO OR-PRG-PROGRAM.OPERATIVA - 1
9168383 140 >>>>> DTR SAR-ZO OR-PRG-VERIFICHE
9168383 120 >>>>> DTR SAR-ZO OR-PRG-SICUREZZA E AMBIENTE
9168383 130 >>>>> DTR SAR-ZO OR-PRG-GESTIONE CONNESSIONI
9168383 100 >>>>> DTR SAR-ZO OR-PROGRAMMAZIONE E GESTIONE

This rows are divided by date ( 2008-04-01, 2008-04-02, ... ) and name of the person responsable ( Jim for 9168383 510, John for 9168383 519, ... ) of the unity.

I like to see:

9168383 510 >>>>> DTR SAR-ZO OR-UOS ORISTANO
9168383 110 >>>>> DTR SAR-ZO OR-PRG-PROGRAM.OPERATIVA
9168383 140 >>>>> DTR SAR-ZO OR-PRG-VERIFICHE
9168383 120 >>>>> DTR SAR-ZO OR-PRG-SICUREZZA E AMBIENTE
9168383 130 >>>>> DTR SAR-ZO OR-PRG-GESTIONE CONNESSIONI
9168383 100 >>>>> DTR SAR-ZO OR-PROGRAMMAZIONE E GESTIONE

And query that counts for all rows like DTR SAR-ZO OR and counts for all rows the same to:

9168383 510 >>>>> DTR SAR-ZO OR-UOS ORISTANO
9168383 110 >>>>> DTR SAR-ZO OR-PRG-PROGRAM.OPERATIVA
9168383 140 >>>>> DTR SAR-ZO OR-PRG-VERIFICHE
9168383 120 >>>>> DTR SAR-ZO OR-PRG-SICUREZZA E AMBIENTE
9168383 130 >>>>> DTR SAR-ZO OR-PRG-GESTIONE CONNESSIONI
9168383 100 >>>>> DTR SAR-ZO OR-PROGRAMMAZIONE E GESTIONE

You understand me ?

If you don't understand all this I can send you the original table mysql.

Thans for your attention.
Viki
Apr 25 '08 #3
deric
92 New Member
Yeah, sorry, it is hard to understand.
You may post the table schema here.

How did you arrive with the rows that you want to see? I mean, what are the conditions/requirements to get them? Through date, person responsible, or what?

Please supply more input... don't hesitate to post a long message, if that will clearly explain what you're trying to say.



***************
To any moderator:
This is not an ASP problem, but a mySQL's. Please move this so that it will be better helped. Thanks.
Apr 25 '08 #4
viki1967
263 Contributor
OK Deric, thanks for your help.

This is the input table MySQL:

http://www.complessobandisticopalomb...ki1967/tbl.zip

Output:

http://www.complessobandisticopalomb...7/immagine.jpg

Please help me...
Viki
Apr 25 '08 #5
deric
92 New Member
So "DTR SAR-ZO OR" is fixed? No other values that will start differently?
My problem is, where did you get the code '9168383500"? In you table, there is no row with that code... Anyway, I think you can work it out for yourself now.

Try this simple approach:
Expand|Select|Wrap|Line Numbers
  1. SELECT '9168383500' AS CODE, 'DTR SAR-ZO OR' AS NAME, COUNT(*) AS NUMBER FROM tbl WHERE Name LIKE 'DTR SAR-ZO OR%'
  2.  
  3. UNION
  4.  
  5. SELECT DISTINCT Code, Name, COUNT(*) FROM tbl WHERE NAME LIKE 'DTR SAR-ZO OR%' GROUP BY Name
The above code will first get the count of all the rows with DTR SAR-ZO OR on their name, then combine it with the count of all the rows grouped according to Name.
Apr 26 '08 #6
viki1967
263 Contributor
thanks your query working !!!
Apr 26 '08 #7
deric
92 New Member
That's good to know. Cheers!
Apr 28 '08 #8
DrBunchman
979 Recognized Expert Contributor
To any moderator:
This is not an ASP problem, but a mySQL's. Please move this so that it will be better helped. Thanks.
Done (sorry only just noticed this post!).
Apr 28 '08 #9

Sign in to post your reply or Sign up for a free account.

Similar topics

5
by: Ken1 | last post by:
I am going to drop a primary key from one column and create a new column to be used as primary key in an existing database. The old column was a date column which someone earlier though was a good...
1
by: Axier | last post by:
Hi, I wonder how this can happen. A "not null" field is set to "" even if a sequence should set this to next sequence number. Ok, I know it is not set to null, it is set to '' which is proven...
0
by: Axier | last post by:
Hi, I wonder how this can happen. A "not null" field is set to "" even if a sequence should set this to next sequence number. Ok, I know it is not set to null, it is set to '' which is proven...
4
by: Eric E | last post by:
Hi, I have a question about sequences. I need a field to have values with no holes in the sequence. However, the values do not need to be in order. My users will draw a number or numbers from...
4
by: bboyle18 | last post by:
Hi, I am working with a table sorting script which can be found here http://www.workingwith.me.uk/articles/scripting/standardista_table_sorting This script works very nicely, but when there is a...
11
by: Wilfried Mestdagh | last post by:
Hi, does foreach guarantees the sequence order starting from index 0 ? -- rgds, Wilfried http://www.mestdagh.biz
4
by: Szymon Dembek | last post by:
Hi Recently I did some DB2 and ODBC coding in Visual FoxPro. I bumped on a problem I cannot resolve. When I issue a delete statement that deletes no rows (no rows qualify for the WHERE...
0
by: jsreddy | last post by:
Hi All, I am having 4 text boxes in a Gridview Template Column. The Tab Sequence is set to 0 - 4. the tab sequence works fine when i have only one Row. if i am adding one more row to grid then tab...
8
by: arachno | last post by:
My Oracle sequences seem to be auto-incrementing themselves "over time". My row ID's are sequenced like this: 1, 4, 5, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 41, etc I'm using...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
1
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
muto222
php
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.