|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
Calculated ORDER BY?
Hi,
Today I got a request to see if it's possible to join 2 columns together and base my ORDER BY upon that. This is what I have, working fine: CREATE VIEW user.view AS SELECT TOP 3 Id, Naam, Host, Woonplaats, IdAbon, WidthH, HeightH, YesCount FROM user.table WHERE (IdAbon = 3) AND (Foto = 1) ORDER BY YesCount Point is now, to sort the list on a combined value of YesCount & Datum Datum is a date value, off course, and YesCount is an integer. When I do this: CREATE VIEW user.view AS SELECT TOP 3 Id, Naam, Host, Woonplaats, IdAbon, WidthH, HeightH, YesCount, Datum FROM user.table WHERE (IdAbon = 3) AND (Foto = 1) ORDER BY (YesCount+Datum) syntax check turns out succesfull, but I can't save the view. Error code: "Error 4511: Could not perform CREATE VIEW because no column name was specified for column 10." Which basically means, he wants the expression (YesCount+Datum) as a new column. How can I fix this? Or, any other suggestions on how to fix it? Thanx in Adv. |
|
#2
|
|||
|
|||
|
Code:
CREATE VIEW user.view AS SELECT TOP 3 Id, Naam, Host, Woonplaats, IdAbon, WidthH, HeightH, YesCount, Datum,yesCount+datum as oc FROM user.table WHERE (IdAbon = 3) AND (Foto = 1) ORDER BY oc |
|
#3
|
|||
|
|||
|
WAUW!
it worked (no errors), that's for sure. Now testing; see if it gives the results I want it to.. Looks like it is going to work! MANY & GREAT THANX! Phi |
![]() |
| Viewing: Dev Shed Forums > Databases > MS SQL Development > Calculated ORDER BY? |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|
|