473,804 Members | 3,802 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Extraction with query

263 Contributor
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 1213
viki1967
263 Contributor
Your help please...

Apr 4 '08 #2
viki1967
263 Contributor
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
3436
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 text file and inserts it into a database. But right now i'm stuck at finding a way to code it so the text extraction doesn't start till after the second set of dashes, here is part of text file. I want to extract ACL ET AL SNIPELK 8-27-70-18 and so...
2
2977
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. Jason
1
2339
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 can be negative or positive. All numbers can be stored in a single byte. My questions is: can ifstream extraction into an int see the leading zero and interpret the number as hex and can I ask the ifstream, right after the extraction, if the value I...
1
1972
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, lname,and age . I'd like to dump the results as a single file in the following format: As after I have dumped the results I need to import them into another app that uses the format fname:lname:age .
3
2334
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 license plate from an image captured. So, i wonder how can this be done? Actually i'm thinking of something like detect the image pixels of the license plate since the license plate that i'm gonna work on at this stage is black and white in color. So that...
16
4353
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 <string>
0
1053
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 information in the SQL database, and then extracts the additional data that is attached to that ID number, but darned if i can figure out how to do it. Id really like to avoid having to look through the database myself, as this is going to happen quite...
5
1419
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. 1. table(s) affected 2. column(s) affected 3. action performed on data (ie. update, insert, select, delete) 4. previous data for each row and column effected (if data changed or
5
2132
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." (http://newdata.box.sk/bx/c/htm/ch16.htm)
0
9706
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10569
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
10315
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10075
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9140
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7615
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5519
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
4295
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3815
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.