SQL Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
User Name:
Password:
Remember me
Go Back   ASP Free ForumsDatabaseSQL Development

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread ASP Free Forums Sponsor:
  #1  
Old March 28th, 2009, 01:24 AM
krish06 krish06 is offline
Registered User
ASP Free Newbie (0 - 499 posts)
 
Join Date: Mar 2009
Posts: 1 krish06 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 27 m 38 sec
Reputation Power: 0
Query - General - Select query..(Quite urgent)..

Hi Friends,

in my application i need to do the following..

i have a one tbl(named as tbl1) and have the records like the following


tbl1
id lotno qty type serialno
0 43243 8.0 test 123456
0 54236 8.7 result 123456
0 34535 8.8 return 123456

in the above table i have 3 type of record for the same serial no..so in that
i need to insert into these 3 types records into one row at another table

like the following..
tbl2
qty test(type of tbl1) result return
8.0 42243(lotno of tbl 1) 54236 34535


the above is output i need..

actully in this table(tbl2)all the coumns (based on tbl1 type)..so i need to select lotno on the first table(tbl1) based on the type and insert into one row like the above output table(tb2) and the qty is based type test.

and in my first table(tbl1) , here i showed only one serialno , but actually i have many serialno like that.. each serial no have 3 type os records and some have 2 types of records

what query will make this things..

i am using mysql datbase

and really quite urgent..

waiting for your valuable reply..

with regards,
krish

Reply With Quote
  #2  
Old May 1st, 2009, 08:22 PM
June7 June7 is offline
Contributing User
Click here for more information.
 
Join Date: Apr 2009
Location: The Great Land
Posts: 1,110 June7 User rank is Captain (20000 - 30000 Reputation Level)June7 User rank is Captain (20000 - 30000 Reputation Level)June7 User rank is Captain (20000 - 30000 Reputation Level)June7 User rank is Captain (20000 - 30000 Reputation Level)June7 User rank is Captain (20000 - 30000 Reputation Level)June7 User rank is Captain (20000 - 30000 Reputation Level)June7 User rank is Captain (20000 - 30000 Reputation Level)June7 User rank is Captain (20000 - 30000 Reputation Level)June7 User rank is Captain (20000 - 30000 Reputation Level) 
Time spent in forums: 2 Weeks 21 h 59 m 11 sec
Reputation Power: 240
Hope you have your answer by now. Visit SQL website to learn SQL language. For starters, get data with a query something like:

"SELECT lotno FROM tbl1 WHERE type=" & textBoxType

Then use UPDATE, INSERT commands to save data. This is very rough because could not really follow your narrative.

Reply With Quote
  #3  
Old May 12th, 2009, 01:52 AM
bklr bklr is offline
Registered User
ASP Free Newbie (0 - 499 posts)
 
Join Date: Feb 2009
Posts: 28 bklr User rank is Sergeant (500 - 2000 Reputation Level)bklr User rank is Sergeant (500 - 2000 Reputation Level)bklr User rank is Sergeant (500 - 2000 Reputation Level)bklr User rank is Sergeant (500 - 2000 Reputation Level)bklr User rank is Sergeant (500 - 2000 Reputation Level) 
Time spent in forums: 3 h 58 m 49 sec
Reputation Power: 0
declare @t table(id int, lotno int,qty decimal(18,2), types varchar(32), serialno int)
insert into @t select 0, 43243, 8.0, 'test', 123456
insert into @t select 0, 54236, 8.7, 'result', 123456
insert into @t select 0, 34535, 8.8, 'return', 123456


select min(qty),max([test]),max([result]),max([return])
from @t
pivot (max(lotno) for types in ([test],[result],[return]))p

use dynamic crosstab too for sql2000
pivot will work in sql2005 only.
check this link too
http://sqlblogcasts.com/blogs/madhivanan/archive/2007/08/27/dynamic-crosstab-with-multiple-pivot-columns.aspx

Reply With Quote
  #4  
Old October 23rd, 2009, 01:17 AM
sakthi.tnj sakthi.tnj is offline
Registered User
ASP Free Newbie (0 - 499 posts)
 
Join Date: Sep 2009
Posts: 24 sakthi.tnj User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 8 h 45 m 13 sec
Reputation Power: 0
Re:Select Query

Hi, I hope that the below SQL query will be useful for you


Select isnull(test.qty,0) as [Qty], isnull(test.lotno,0) as [Test],isnull(result.lotno,0) as [result]
,isnull([return].lotno,0) as [Return]
from
(select id,qty,lotno from test2 where type = 'test')test
right outer join(select id, lotno from test2 where type = 'result')result on test.id = result.id
right outer join(select id, lotno from test2 where type = 'return') [return] on test.id = [return].id
or result.id = [return].id


Note: test2 is a table name

Thanks & Regards
Sakthimeenakshi.S

Reply With Quote
Reply

Viewing: ASP Free ForumsDatabaseSQL Development > Query - General - Select query..(Quite urgent)..


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump





 Free IT White Papers!
 
Create the Optimal Architecture for your Critical Applications
Warburton's the largest independently owned bakery in the UK faced a number of difficult challenges in providing the most robust yet efficient IT infrastructure for their organization's success. IBM's services combined with their xSeries servers created the perfect platform for their SAP environment with sufficient flexibility, and did so in very time effective fashion.

 
Five Best Practices for Deploying a Successful Service-Oriented Architecture
This white paper describes the benefits you can expect with SOA, and how IBM can help take your business there.

 
Gartner Magic Quadrant for Application Delivery Controllers
Gartner summarizes its view on Application Delivery Controllers, evaluates strengths and weaknesses of solutions, and provides Magic Quadrant reporting for a quick comparison across all vendors. Learn from Gartner how you can benefit from an all-in-one device like Citrix NetScaler that delivers the highest levels of availability, performance and security.

 
Knowledge is Power
What you don't know can hurt you, and is likely costing you money and increasing your security risks during an era of scarce resources. This white paper proposes six key strategies that enterprise security managers can use to improve their network defense posture.

 
Rationalizing the Multi-Tool Environment
The rationalized multi-tool approach is flexible, scalable and cost effective. It provides the necessary input to the IT service management business processes. It preserves prior investments in monitoring tools, empowers technologists to select the best tools with which to do their jobs, and enhances effective response to incidents.

 

Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2010 by Developer Shed. All rights reserved. DS Cluster 10 Hosted by Hostway
For more Enterprise Application Development news, visit eWeek