ORDER BY

ORDER BY

am 04.08.2006 10:30:11 von weetat.yeo

Hi all ,

I have 2 table as show below :
When do join the 2 table using SQL statement , how i going to order
by Table A sw_version then Table B card_sw_version_no column ? Anyone
have ideas ? Thanks

Select A.*,B,*
from Table A , Table B
where A.serial_no = B.serial_no

Table A

serial no model_no sw_version_no
123456 W89489 1.3
83944 W2090 8.9
123456-1 W89489-a 2.3
83944-1 W2090-a 18.9(A)
123456-2 W89489-b 6.1
83944-2 W2090 -b 1.2

Table B

serial no card_model_no card_sw_version_no
123456 W89489-c 1.1
83944 W2090-c 1.1
123456-1 W89489-c 2.1
83944-1 W2090-d 1.5
123456-2 W89489-f 1.2
83944-2 W2090 -g 1.8

Re: ORDER BY

am 04.08.2006 19:19:11 von Cirene

Off the top of my head I would do a union query. You can then add a
column that will let you have your own sort order.

Here is some air code:

select a.*, "a" as sorttemp from tableA a inner join tableB b on
a.serial_no = b.serial_no
union
select b.*, "b" as sorttemp from tableB b inner join tableA a on
a.serial_no = b.serial_no
order by sorttemp;

There is probably a more elegant way to do this, but I don't know what
it is right now.

weetat.yeo@gmail.com wrote:
> Hi all ,
>
> I have 2 table as show below :
> When do join the 2 table using SQL statement , how i going to order
> by Table A sw_version then Table B card_sw_version_no column ? Anyone
> have ideas ? Thanks
>
> Select A.*,B,*
> from Table A , Table B
> where A.serial_no = B.serial_no
>
> Table A
>
> serial no model_no sw_version_no
> 123456 W89489 1.3
> 83944 W2090 8.9
> 123456-1 W89489-a 2.3
> 83944-1 W2090-a 18.9(A)
> 123456-2 W89489-b 6.1
> 83944-2 W2090 -b 1.2
>
> Table B
>
> serial no card_model_no card_sw_version_no
> 123456 W89489-c 1.1
> 83944 W2090-c 1.1
> 123456-1 W89489-c 2.1
> 83944-1 W2090-d 1.5
> 123456-2 W89489-f 1.2
> 83944-2 W2090 -g 1.8
>