Link to home
Start Free TrialLog in
Avatar of davidi1
davidi1Flag for India

asked on

SQL 2008 Query Help

Team,

I need to create a table which shows days of the week. Data is from Database.

i.e.,

Team        Sun        Mon         Tue     Wed        Thur        Fri      Sat

Headers are static.

Based on current date, (11/25/2010) which is a "Thurs" day, this data should come in Thurs field and all the before days should calculate automatically based on that respective date. Fri & Sat should be empty as no data will be there in the database.

If the current date is Sun, then rest of the data should be blank.

Pls guide me to write a query which will do this function.

Thanks,
David
Avatar of cyberkiwi
cyberkiwi
Flag of New Zealand image

Do you want to create a table or a query?
"this data should come in Thurs field"
Can you please explain what that means?  Data from some table that has a date column?
Does the query always show only 1 row (current week)?
Where does Team fit in?
Avatar of davidi1

ASKER

sorry. my bad. let me clarify more.

SQL Table Name: RawData

Fields:

TeamName, Date, Closecount

I already run a query to pullup dynamic table which will display last 7 days of data. however my org doesnt want that. they want to keep the headers static & want me to modify the query to satisfy the headers.

for every day ("Sun") ex:

5 rows will be generated as result.

I need to populate the same data with respect to days, Sun, Mon, Tue.., etc..,

lemme know if you have more questions.., sorry.., answering your question real fast as im jumping to a meeting. will be back to you in 15 mins.

Thanks,
David
ASKER CERTIFIED SOLUTION
Avatar of HainKurt
HainKurt
Flag of Canada image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Sorry, but it is still not clear to me

for every day ("Sun") ex:
5 rows will be generated as result.

Why are there 5 rows for Sunday?
If you run it on a Thursday, I know you mentioned that Fri/Sat should be blank, but are the preceeding days also blank?
Do you want the closecount value from the table in the columns under the days, or the dates?
Avatar of davidi1

ASKER

Nevermind cyberkiwi.  Hainkurt resolved my problem.

Hainkurt: Bingo. This is exactly what i was looking for. Thanks. Its works great.

Thanks,
David