User Profile

Collapse

Profile Sidebar

Collapse
ShadowTech
ShadowTech
Last Activity: Aug 13 '08, 11:30 PM
Joined: Aug 12 '08
Location:
  •  
  • Time
  • Show
  • Source
Clear All
new posts

  • ShadowTech
    replied to Complex Query
    That works well, I was hoping I could do it with one subquery join.
    I was actually looking for a rolling year so I jsut changed the where clause on the date to this.
    Code:
    select [Passenger ID],count(*) as [Total flights],max(FlightDate) as [Last Flight Date]
    from PassengerFlights p inner join Flights f on p.FlightID=f.FlightID
    where FlightDate >= dateadd(day,-365,GetDate())
    group by [Passenger ID]
    )
    ...
    See more | Go to post

    Leave a comment:


  • Try declaring the variable
    [code=sql]
    Declare @orderBy char(1)
    Set @orderBy = 'A'
    SELECT START_DATE, CALL_ID
    FROM CALL
    ORDER BY CASE WHEN @orderBy = 'A' THEN START_DATE, CALL_ID END[/code]...
    See more | Go to post

    Leave a comment:


  • ShadowTech
    started a topic Complex Query

    Complex Query

    Hope someone can help, this has really stumped me in terms of the best way to get the data with the least code (or at least most effecient code).

    I have two tables

    Flights
    FlightID - UniqueID primary key
    FlightName - Text
    FlightDate - Date

    PassengerFlight s
    Passenger ID - UniqueID primary key
    Flight ID - UniqueID foriegn key
    Last Name - Text
    First Name -...
    See more | Go to post
No activity results to display
Show More
Working...