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, 02: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, 09:22 PM
June7 June7 is offline
Contributing User
Click here for more information.
 
Join Date: Apr 2009
Location: The Great Land
Posts: 536 June7 User rank is First Lieutenant (10000 - 20000 Reputation Level)June7 User rank is First Lieutenant (10000 - 20000 Reputation Level)June7 User rank is First Lieutenant (10000 - 20000 Reputation Level)June7 User rank is First Lieutenant (10000 - 20000 Reputation Level)June7 User rank is First Lieutenant (10000 - 20000 Reputation Level)June7 User rank is First Lieutenant (10000 - 20000 Reputation Level)June7 User rank is First Lieutenant (10000 - 20000 Reputation Level)June7 User rank is First Lieutenant (10000 - 20000 Reputation Level) 
Time spent in forums: 1 Week 13 h 58 m 7 sec
Reputation Power: 124
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, 02: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 53 m 3 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, 02:17 AM
sakthi.tnj sakthi.tnj is offline
Registered User
ASP Free Newbie (0 - 499 posts)
 
Join Date: Sep 2009
Posts: 23 sakthi.tnj User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 7 h 48 m 35 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!
 
How to Present Effectively Online
This white paper offers practical and actionable advice on the key steps that any presenter should consider as they plan and execute a Webinar or online meeting.

 
Open Source Security Myths
Open Source Software (OSS) is computer software whose source code is available to the general public with relaxed or non-existent intellectual property restrictions (or arrangement such as the public domain), and is usually developed with the input of many contributors.

 
Power and Cooling Capacity Management for Data Centers
This paper describes the principles for achieving power and cooling capacity management.

 
Scalable, Fault-Tolerant NAS for Oracle - The Next Generation
For several years NAS has been evolving as a storage alternative for Oracle databases, and for good reason: NAS is quite often the simplest, most cost-effective storage approach for Oracle. Learn about the benefits that HP's approach to scalable NAS brings to Oracle environments in this comprehensive white paper.

 
Understanding Web Application Security Challenges
This white paper discusses many common threats and preventive measures for Web application security, and explains what you can do to help protect your organization.

 

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





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