Hello,
I can't solve the following problem:
I have 2 tables
I tried in Access and in ASP
How can I use a SELECT in an ORDER BY clause? Is there another way to do it, if possible without a stored procedure? Any help would be great because i need this feature badly for my work.
Many thanks
p.s.
Are there any good guides on how to create querys for multiple many to many relationships? I have four m-to-m relationshipsin my database and it is driving me nuts to handle them
I can't solve the following problem:
I have 2 tables
Code:
1: Currency C
name value
1 EUR 1,0000 (Euro
2 USD 0,8957 (US Dollar)
3 GBP 0,6453 (British Pound)
2: transactions T
text price currency
1 abc 111 EUR
2 def 222 USD
3 hij 333 USD
4 klm 444 EUR
I can now easy select table with the price in any currency i like:
SELECT T.*,
(SELECT
(SELECT T.price/C.value FROM C
WHERE C.name=T.currency
)*C.value FROM C WHERE name='GBP') AS value_in_british_pound
text price currency value_in_british_pound
1 abc 111 EUR 123,123
2 def 222 USD 234,234
3 hij 333 USD 345,345
4 klm 444 EUR 456,456
that works perfect
However, sorting by value_in_british_pound does not work
ORDER BY value_in_british_pound --->Syntax Error
ORDER BY (SELECT
(SELECT T.price/C.value FROM C
WHERE C.name=T.currency
)*C.value FROM C WHERE name='GBP')
---> Syntax Error
ORDER BY (SELECT T.price/C.value FROM C
WHERE C.name=T.currency )
---> Syntax Error
How can I use a SELECT in an ORDER BY clause? Is there another way to do it, if possible without a stored procedure? Any help would be great because i need this feature badly for my work.
Many thanks
p.s.
Are there any good guides on how to create querys for multiple many to many relationships? I have four m-to-m relationshipsin my database and it is driving me nuts to handle them