Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 Development Tools
 ASP.NET
 Sorting

Author  Topic 

nanygadu
Starting Member

4 Posts

Posted - 2007-10-03 : 07:01:01
hai folks...
i have four different tables.I need to get data from these four tables and should place in another grid view.
how? that too in a particular order.

for example..
table 1 contains-->1,2,a,4
table2-->f,t,h,n
table3-->g,m,k,o,p

now fourth table should display

a
m
n
4

i need to display i the same order.

can u guys plese hepl me..

SwePeso
Patron Saint of Lost Yaks

30421 Posts

Posted - 2007-10-03 : 07:04:10
Is "1,2,a,4" four different columns in same record, or is "1,2,a,4" four records with one column?

How do you expect us to know if you don't tell us?



E 12°55'05.25"
N 56°04'39.16"
Go to Top of Page

SwePeso
Patron Saint of Lost Yaks

30421 Posts

Posted - 2007-10-03 : 07:05:47
SELECT Table1.Col1 FROM Table1 WHERE Table1.ID = 3 UNION ALL
SELECT Table3.Col1 FROM Table3 WHERE Table3.ID = 2 UNION ALL
SELECT Table2.Col1 FROM Table2 WHERE Table2.ID = 4 UNION ALL
SELECT Table1.Col1 FROM Table1 WHERE Table1.ID = 4



E 12°55'05.25"
N 56°04'39.16"
Go to Top of Page

nanygadu
Starting Member

4 Posts

Posted - 2007-10-03 : 07:06:31
they are columns.....
am sorry..
Go to Top of Page

SwePeso
Patron Saint of Lost Yaks

30421 Posts

Posted - 2007-10-03 : 07:16:59
SELECT Table1.Col3 FROM Table1 WHERE Table1.ID = 1 UNION ALL
SELECT Table3.Col2 FROM Table3 WHERE Table3.ID = 1 UNION ALL
SELECT Table2.Col4 FROM Table2 WHERE Table2.ID = 1 UNION ALL
SELECT Table1.Col4 FROM Table1 WHERE Table1.ID = 1



E 12°55'05.25"
N 56°04'39.16"
Go to Top of Page

nanygadu
Starting Member

4 Posts

Posted - 2007-10-03 : 07:17:11
SELECT 'Release Status' AS Expr1, Status, Actual_Rel_Date, NULL AS Expr2 FROM SW_Versions WHERE (Version_ID = @Version_ID) UNION ALL SELECT 'Pre Release Check' AS Expr1, Pre_Final_Status, Pre_Start, Pre_End FROM PreRelease_Final WHERE (Ver_ID = @Version_ID) UNION ALL SELECT 'QM ' AS Expr1, QM_Status, Start_Date, End_Date FROM QM_Status WHERE (Ver_ID = @Ver_ID) UNION ALL SELECT 'FT' AS Expr1, FT_Final_Status, Start_Date, End_Date FROM FT_Final_Status WHERE (Ver_ID = @Ver_ID) ORDER BY NULL

the above is my SQL command.i need to get in the same order.
but its not coming in that order.i have not given any sorting orders.
as per the above a=command..i need to get in the following order
Release Status
Pre Release Check
QM
FT
Go to Top of Page

SwePeso
Patron Saint of Lost Yaks

30421 Posts

Posted - 2007-10-03 : 07:20:31
[code]SELECT Expr1,
Status,
Actual_Rel_Date,
Expr2
FROM (
SELECT 'Release Status' AS Expr1,
Status,
Actual_Rel_Date,
NULL AS Expr2,
1 AS myOrder
FROM SW_Versions
WHERE Version_ID = @Version_ID

UNION ALL

SELECT 'Pre Release Check' AS Expr1,
Pre_Final_Status,
Pre_Start,
Pre_End,
3 AS myOrder
FROM PreRelease_Final
WHERE Ver_ID = @Version_ID

UNION ALL

SELECT 'QM' AS Expr1,
QM_Status,
Start_Date,
End_Date,
4 AS myOrder
FROM QM_Status
WHERE Ver_ID = @Ver_ID

UNION ALL

SELECT 'FT' AS Expr1,
FT_Final_Status,
Start_Date,
End_Date,
2 AS myOrder
FROM FT_Final_Status
WHERE Ver_ID = @Ver_ID
) AS d
ORDER BY MyOrder[/code]
E 12°55'05.25"
N 56°04'39.16"
Go to Top of Page

nanygadu
Starting Member

4 Posts

Posted - 2007-10-04 : 01:04:20
Thanks a lot.It is working
Go to Top of Page
   

- Advertisement -