Click here to Skip to main content
15,923,557 members
Home / Discussions / Database
   

Database

 
AnswerOpen the database as read/only Pin
Ennis Ray Lynch, Jr.13-Jul-06 9:18
Ennis Ray Lynch, Jr.13-Jul-06 9:18 
QuestionRecursive SELECT paradox!!! [modified] Pin
innocent7313-Jul-06 3:40
innocent7313-Jul-06 3:40 
AnswerRe: Recursive SELECT paradox!!! Pin
Eric Dahlvang13-Jul-06 4:13
Eric Dahlvang13-Jul-06 4:13 
GeneralRe: Recursive SELECT paradox!!! [modified] Pin
innocent7313-Jul-06 4:30
innocent7313-Jul-06 4:30 
GeneralRe: Recursive SELECT paradox!!! Pin
Eric Dahlvang13-Jul-06 4:37
Eric Dahlvang13-Jul-06 4:37 
GeneralRe: Recursive SELECT paradox!!! Pin
innocent7313-Jul-06 4:40
innocent7313-Jul-06 4:40 
GeneralThe best thing Pin
Ennis Ray Lynch, Jr.13-Jul-06 5:20
Ennis Ray Lynch, Jr.13-Jul-06 5:20 
GeneralRe: Recursive SELECT paradox!!! Pin
Eric Dahlvang13-Jul-06 5:50
Eric Dahlvang13-Jul-06 5:50 
This isn't very pretty...and there are probably better ways to do what you want. But, if there is only ever two drivers, you can still get it all into another table with just one SQL:
insert into voyage_end2 (voyage_id,platenumber, startdate,Driver1,Driver2)
SELECT (SELECT TOP 1 voyage_id 
        FROM Voyage_End a where a.platenumber = b.platenumber and a.startdate = b.startdate) as voyage_id, 
PlateNumber,StartDate, 
(SELECT TOP 1 Driver1 
        FROM Voyage_End a where a.platenumber = b.platenumber and a.startdate = b.startdate order by Driver1) as Driver1, 
(SELECT TOP 1 Driver1 
        FROM Voyage_End a where a.platenumber = b.platenumber and a.startdate = b.startdate and 
	(SELECT TOP 1 Driver1 FROM Voyage_End a where a.platenumber = b.platenumber and a.startdate = b.startdate order by Driver1)  != Driver1 order by Driver1 desc) as Driver2
FROM Voyage_End b
 GROUP BY platenumber, startdate

However, your best long term solution is to do as Ennis Ray Lynch, Jr. has suggested and modify your table structure.

--EricDV Sig---------
Some problems are so complex that you have to be highly intelligent and well informed just to be undecided about them.
- Laurence J. Peters

QuestionSQL replication using .net Pin
farshad.A13-Jul-06 2:38
farshad.A13-Jul-06 2:38 
QuestionSQl file Log Pin
AnhTin12-Jul-06 18:13
AnhTin12-Jul-06 18:13 
AnswerRe: SQl file Log Pin
kumarprabhakar7412-Jul-06 18:37
kumarprabhakar7412-Jul-06 18:37 
GeneralRe: SQl file Log Pin
AnhTin12-Jul-06 18:59
AnhTin12-Jul-06 18:59 
GeneralRe: SQl file Log Pin
WoutL12-Jul-06 20:40
WoutL12-Jul-06 20:40 
AnswerRe: SQl file Log [modified] Pin
Mike Dimmick13-Jul-06 3:18
Mike Dimmick13-Jul-06 3:18 
QuestionComparing strings in SQL Pin
kscadi12-Jul-06 17:42
kscadi12-Jul-06 17:42 
AnswerRe: Comparing strings in SQL [modified] Pin
technomanceraus12-Jul-06 18:09
technomanceraus12-Jul-06 18:09 
Questiongetting query names Pin
hamidreza_buddy12-Jul-06 7:44
hamidreza_buddy12-Jul-06 7:44 
AnswerRe: getting query names Pin
leckey12-Jul-06 7:58
leckey12-Jul-06 7:58 
GeneralRe: getting query names Pin
Eric Dahlvang12-Jul-06 8:04
Eric Dahlvang12-Jul-06 8:04 
GeneralRe: getting query names Pin
hamidreza_buddy12-Jul-06 8:07
hamidreza_buddy12-Jul-06 8:07 
AnswerRe: getting query names Pin
Eric Dahlvang12-Jul-06 8:06
Eric Dahlvang12-Jul-06 8:06 
GeneralRe: getting query names Pin
hamidreza_buddy12-Jul-06 8:10
hamidreza_buddy12-Jul-06 8:10 
AnswerRe: getting query names [modified] Pin
Scott Serl13-Jul-06 6:26
Scott Serl13-Jul-06 6:26 
QuestionUpdating a datasource through a DataGrid Pin
hamidreza_buddy12-Jul-06 7:05
hamidreza_buddy12-Jul-06 7:05 
AnswerRe: Updating a datasource through a DataGrid Pin
leckey12-Jul-06 7:25
leckey12-Jul-06 7:25 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.