473,395 Members | 1,688 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

Extraction with query

263 100+
Hi everyone.

I have this table :



Need extraction query:

***************************************

where SG = PP

Field IR ==> IRE ==> 4 rows
Field IR ==> IRE ==> 3 rows x Uo = 91
Field IR ==> IRE ==> 1 row x Uo = 93

Field IR ==> MAN ==> 3 rows
Field IR ==> MAN ==> 2 rows x Uo = 95
Field IR ==> MAN ==> 1 row x Uo = 96

Field IR ==> VAS ==> 1 row
Field IR ==> VAS ==> 1 row x Uo = 93

Field IR ==> IMI ==> 4 rows
Field IR ==> IMI ==> 1 row x Uo = 93
Field IR ==> IMI ==> 2 rows x Uo = 91
Field IR ==> IMI ==> 1 row x Uo = 96

***************************************

where SG = AS

Field SG ==> 4 rows
Field SG ==> 1 row x Uo = 95
Field SG ==> 2 rows x Uo = 93
Field SG ==> 1 row x Uo = 96

***************************************

It's possible with single query ?

Regards
Viki
Apr 4 '08 #1
2 1202
viki1967
263 100+
Your help please...

Apr 4 '08 #2
viki1967
263 100+
OK, that is the solution... :

Expand|Select|Wrap|Line Numbers
  1.  
  2. <%
  3.  
  4. sDatabaseConnection = "DRIVER={MySQL ODBC 3.51 Driver};"_
  5.                             & "SERVER=localhost;"_
  6.                             & "DATABASE=test;"_
  7.                             & "UID=root;PWD=XXXXXX; OPTION=35;"
  8.  
  9. Set connCount = Server.Createobject("ADODB.Connection")
  10. connCount.open sDatabaseConnection                                                                        
  11.  
  12.    Query = " SELECT "
  13.    Query = Query & " ir, "
  14.    Query = Query & " uo, "
  15.    Query = Query & " count(*) as tot_uo "
  16.    Query = Query & " FROM tbl_fraser "
  17.    Query = Query & " GROUP BY ir, uo "
  18.    Query = Query & " ORDER BY ir ASC "
  19.  
  20.    response.write query & "<br><br>"
  21.  
  22.    Set Rs = Server.CreateObject("ADODB.Recordset")
  23.    Rs.Open Query, connCount
  24.  
  25.     if not Rs.eof then
  26.     count = 0
  27.  
  28.          strUoCount = 0
  29.             Rs.MoveFirst()
  30.                   strIR = Rs("ir")
  31.                         Do While Not Rs.EOF
  32.  
  33.  
  34.                         if strIR <> Rs("ir") then                        
  35.                               stampa = "TOT ir ----> '" & strIR & "'---->" & strUoCount & "<br>" & stampa & "<br>"
  36.                                     Response.Write stampa
  37.                                           strUoCount = 0
  38.                               stampa = ""
  39.                               strIR = Rs("ir")
  40.                         end if
  41.  
  42.                               strUoCount = strUOCount + cLng(Rs("tot_uo"))
  43.                               stampa = stampa & "IR ---->'" & Rs("ir") & "'----> UO ---->'" & Rs("uo") & "'---->" & Rs("tot_uo") & "<br>"
  44.            Rs.MoveNext()
  45.  
  46.                        if Rs.EOF then
  47.                              stampa = "TOT ir ----> '" & strIR & "'---->" & strUoCount & "<br>" & stampa & "<br>"
  48.                              Response.Write stampa
  49.                        end if
  50.  
  51.            Loop
  52.  
  53.    end if
  54.  
  55. Rs.Close
  56. Set Rs = Nothing
  57.  
  58.  
  59. connCount.Close
  60. Set connCount = Nothing
  61.  
  62. %>
  63.  
Apr 7 '08 #3

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

Similar topics

3
by: Kangol kangoll | last post by:
hi, i've been trying to figure out how to make visual basic start extracting text at a certain line to when i tell it to stop. I am making trying to make a program where it extracts text from a...
2
by: Jason Huang | last post by:
Hi, Would someone show me how to do the data extraction to Excel in ASP.Net using C# web form? I am not familiar with VB, so I am asking someone to help me out! Any help will be appreciated. ...
1
by: James Lehman | last post by:
Hello. I want to write a program that reads AutoCAD shape (font) files. They are written with the convention that hexadecimal values have a leading zero and decimal values do not. All numbers...
1
by: b0red | last post by:
Hi All, Thanks for taking the time to read this post, I appreciate it. Two problems Problem 1 --------- I need help with a query the table contains 35 odd columns I only want fname,...
3
by: dec01louis | last post by:
Hi all, actually i'm now doing something on license plate recognition system for my project. The first step would be the license plate extraction algorithm which means it is needed to extract a...
16
by: EM.Bateman | last post by:
Working on Visual Studio .Net I've implemented a class: #ifndef CONTRIBUTOR_H #define CONTRIBUTOR_H enum Gender {male=1, female, unk}; #include <iostream> #include <iomanip> #include...
0
by: Tbell | last post by:
Hi, Im looking at an excel spreadsheet with about 3500 rows in it, and in each row there is an id number, i would like to create a query that takes each of these rows and compares it to the...
5
by: Dan99 | last post by:
Hello, I am working on auditing interactions with a pgsql database using php. So my question is how can i go about obtaining the following information for by only being provided a pgsql query....
5
by: Taras_96 | last post by:
Hi all, Jesse Liberty writes: "cin.get() >>myVarOne >myVarTwo; // illegal The return value of (cin.get() >myVarOne) is an integer, not an iostream object." ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
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...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
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...

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.