Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2000 Forums
 SQL Server Development (2000)
 Creating a Complex Query

Author  Topic 

jennifer_ann
Starting Member

8 Posts

Posted - 2006-04-10 : 12:35:44
I have the following table
Table Name: Story
Table Columns: user_id, date, name, yr_left, city_origin, country_origin, yr_arrival, city_arrival, state_arrival, address, city, state, zip, AorV (audio or video), filename, approved

I need to create two queries. One based on date in descending order, and one based on country_origin in alphabetical order. For both of these queries, the approved field has to = Y for yes, and when I return results I need it to return everything in the table EXCEPT for the name.

I'm a beginner at SQL queries so I was hoping someone could shed some light and help me??? Thanks a bunch!


Srinika
Master Smack Fu Yak Hacker

1378 Posts

Posted - 2006-04-10 : 12:56:03
Hi jennifer,

U may visit the sites as www.w3schools.com/sql or some similar site for SQL Syntax.

U may need the following query for ur current requirement


Select user_id, date, name, yr_left, city_origin, country_origin, yr_arrival, city_arrival, state_arrival, address, city, state, zip, AorV as [audio or video], filename, approved
from Story
order by country_origin


Srinika
Go to Top of Page

rmason
Starting Member

12 Posts

Posted - 2006-04-11 : 08:52:00
To get you started...

Q1. Select user_id, date, yr_left, city_origin, country_origin, yr_arrival, city_arrival, state_arrival, address, city, state, zip, AorV as [audio or video], filename, approved
from Story
where approved = 'Y'
order by date

Q2. I assume you mean in descending order here also when you say alphabetical?? In the "Order By" clause you can either state DESC or ASC after the fields you want to order by. If this is left out as in my query for Q1 then DESC is implied.

Select user_id, date, yr_left, city_origin, country_origin, yr_arrival, city_arrival, state_arrival, address, city, state, zip, AorV as [audio or video], filename, approved
from Story
where approved = 'Y'
order by country_origin desc
Go to Top of Page
   

- Advertisement -